{"id":26283030,"url":"https://github.com/abin-z/makefiledemo","last_synced_at":"2025-03-14T17:16:29.740Z","repository":{"id":271585331,"uuid":"913923083","full_name":"abin-z/MakefileDemo","owner":"abin-z","description":"一个用于简单项目的Makefile模板","archived":false,"fork":false,"pushed_at":"2025-02-23T13:59:22.000Z","size":188,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-23T14:34:49.855Z","etag":null,"topics":["cpp","demo","makefile","template"],"latest_commit_sha":null,"homepage":"","language":"Makefile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abin-z.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-08T15:59:13.000Z","updated_at":"2025-02-23T14:13:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"a751d564-ce58-42c9-b4a8-e39c4f3622de","html_url":"https://github.com/abin-z/MakefileDemo","commit_stats":null,"previous_names":["abin-z/makefiledemo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abin-z%2FMakefileDemo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abin-z%2FMakefileDemo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abin-z%2FMakefileDemo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abin-z%2FMakefileDemo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abin-z","download_url":"https://codeload.github.com/abin-z/MakefileDemo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243615620,"owners_count":20319733,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","demo","makefile","template"],"created_at":"2025-03-14T17:16:29.252Z","updated_at":"2025-03-14T17:16:29.721Z","avatar_url":"https://github.com/abin-z.png","language":"Makefile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MakefileDemo\n### 一个用于简单项目的Makefile模板\n根目录下的Makefile.bak是一个基本Makefile模板, 适用于简单的Demo代码\n\n- Makefile简单通用, 非常适合demo代码\n- 支持debug和release模式\n- 有单独文件夹保存.o文件和可执行文件\n- 可以根据模板进行自定义或改进\n\n**基本使用步骤** \n\n1. 新建一个文件夹, 例如`hello_demo`.\n\n2. 将`Makefile.bak`复制到新建文件夹(hello_demo)中, 并删除`.bak`后缀.\n\n3. 新建一个`main.cpp`文件, 写打印hello的代码.\n    ```cpp\n    #include \u003ciostream\u003e\n    int main(void)\n    {\n      std::cout \u003c\u003c \"hello makefile.\\n\";\n    }\n    ```\n    \n4. 然后当前文件夹`hello_demo/`的命令行中输入`make`, 就会进入构建过程.\n    ```sh\n    [user@ubuntu hello_demo]$ make \n    mkdir -p obj/debug\n    mkdir -p bin/debug\n    g++ -std=c++17 -Wall -Wextra -Wpedantic -Wconversion -O0 -g  -o obj/debug/main.o -c main.cpp\n    g++ obj/debug/main.o -o bin/debug/main -lpthread\n    [user@ubuntu hello_demo]$ \n    ```\n    \n    - 执行` make r `构建release版本, 执行` make d `构建debug版本, 执行` make al `构建debug和release版本.\n    \n5. 可以看到生成了可执行文件main,执行`./bin/debug/main`命令即可运行\n    ```sh\n    [user@ubuntu hello_demo]$ ./bin/debug/main \n    hello makefile.\n    [user@ubuntu hello_demo]$ \n    ```\n    \n    - 快捷执行指令: `make runr`执行release版本程序,  `make rund`执行debug版本程序.\n    \n6. 可以观察现在的目录架构如下:\n   ```sh\n    [user@ubuntu makefileDemo]$ tree hello_demo/\n    hello_demo/\n    ├── bin\n    │   └── debug\n    │       └── main\n    ├── main.cpp\n    ├── Makefile\n    └── obj\n        └── debug\n            └── main.o\n   \n    4 directories, 4 files\n    [user@ubuntu hello_demo]$ \n   ```\n   \n7. 清除操作: `make clean`\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabin-z%2Fmakefiledemo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabin-z%2Fmakefiledemo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabin-z%2Fmakefiledemo/lists"}