{"id":20382900,"url":"https://github.com/zfb132/simple_cpp","last_synced_at":"2026-06-05T08:31:26.560Z","repository":{"id":130412859,"uuid":"321570765","full_name":"zfb132/simple_cpp","owner":"zfb132","description":"使用VSCode开发C++项目的模板","archived":false,"fork":false,"pushed_at":"2020-12-18T13:15:01.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-04T22:43:09.953Z","etag":null,"topics":["cpp","makefile-template","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/zfb132.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":"2020-12-15T06:12:15.000Z","updated_at":"2023-12-26T13:25:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"f91abf29-8451-46ea-b339-e10be7d4815d","html_url":"https://github.com/zfb132/simple_cpp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zfb132/simple_cpp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zfb132%2Fsimple_cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zfb132%2Fsimple_cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zfb132%2Fsimple_cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zfb132%2Fsimple_cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zfb132","download_url":"https://codeload.github.com/zfb132/simple_cpp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zfb132%2Fsimple_cpp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33937661,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-05T02:00:06.157Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","makefile-template","template"],"created_at":"2024-11-15T02:19:28.370Z","updated_at":"2026-06-05T08:31:26.535Z","avatar_url":"https://github.com/zfb132.png","language":"Makefile","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 简单的C++项目文件结构\n如下：  \n```txt\nsimple_cpp\n├── include\n│   ├── model\n│   │   └── model.h\n│   └── test.h\n├── main.cpp\n├── Makefile\n├── README.md\n└── src\n    ├── model.cpp\n    └── test.cpp\n```\n## 编写C++项目的通用Makefile文件\n内容见[Makefile](https://github.com/zfb132/simple_cpp/tree/main/Makefile)  \n原始版本为[mbcrawfo/GenericMakefile](https://github.com/mbcrawfo/GenericMakefile)  \n使用说明：  \n* 编译（默认编译为`Release`版本）：`make`或者`make release`\n* 编译为调试版本：`make debug`\n* 多线程编译：`make -j12 debug`\n* 显示编译命令（不执行）：`make -n debug`\n* 清除文件：`make clean`\n\n**注意**  \n* 添加头文件[路径](https://github.com/zfb132/simple_cpp/blob/7fb9d08020f99b60c4c83d5fffc9fd8923c2462c/Makefile#L21)  \n`INCLUDES = -I $(SRC_PATH) -I include/`\n\n## 使用VSCode调试代码[可选]\n参考[使用VSCode调试ITensor项目](https://blog.whuzfb.cn/blog/2020/07/04/itensor_vscode/#34-%E6%AD%A3%E5%BC%8F%E7%BC%96%E5%86%99%E4%BB%A3%E7%A0%81)  \n1. 创建文件夹`.vscode`，不要忘记前面的`.`\n2. 在`.vscode`文件夹下为`C/C++`扩展添加配置文件`c_cpp_properties.json`，内容如下\n```json\n{\n    \"configurations\": [\n        {\n            \"name\": \"Linux\",\n            \"includePath\": [\n                \"${workspaceFolder}/**\",\n            ],\n            \"defines\": [],\n            \"compilerPath\": \"/usr/bin/gcc\",\n            \"cStandard\": \"c11\",\n            \"cppStandard\": \"c++17\",\n            \"intelliSenseMode\": \"clang-x64\"\n        }\n    ],\n    \"version\": 4\n}\n```\n3. 在`.vscode`文件夹下添加配置文件`tasks.json`，内容如下\n```json\n{\n    \"version\": \"2.0.0\",\n    \"tasks\": [\n        {\n            \"label\": \"cpp-build\",\n            \"command\": \"make\",\n            \"args\": [],\n            \"type\": \"shell\"\n          },\n          {\n            \"label\": \"cpp-build-debug\",\n            \"command\": \"make\",\n            \"args\": [\n              \"debug\"\n            ],\n            \"type\": \"shell\"\n          },\n          {\n            \"label\": \"cpp-clean\",\n            \"command\": \"make\",\n            \"args\": [\n              \"clean\"\n            ],\n            \"type\": \"shell\"\n          }\n    ]\n}\n```\n4. 在`.vscode`文件夹下添加配置文件`launch.json`，内容如下\n```json\n{\n    \"version\": \"0.2.0\",\n    \"configurations\": [\n        {\n            \"name\": \"(gdb) Launch\",\n            \"type\": \"cppdbg\",\n            \"request\": \"launch\",\n            \"program\": \"${fileDirname}/${fileBasenameNoExtension}-g\",\n            \"args\": [],\n            \"stopAtEntry\": false,\n            \"cwd\": \"${fileDirname}\",\n            \"environment\": [],\n            \"externalConsole\": false,\n            \"MIMode\": \"gdb\",\n            \"miDebuggerPath\": \"gdb\",\n            \"setupCommands\": [\n                {\n                    \"description\": \"Enable pretty-printing for gdb\",\n                    \"text\": \"-enable-pretty-printing\",\n                    \"ignoreFailures\": false,\n                }\n            ],\n            \"preLaunchTask\": \"cpp-build-debug\"\n        }\n    ]\n}\n```\n以上四步执行完毕后的目录如下  \n```txt\nsimple_cpp\n├── include\n│   ├── model\n│   │   └── model.h\n│   └── test.h\n├── main.cpp\n├── Makefile\n├── README.md\n├── src\n│   ├── model.cpp\n│   └── test.cpp\n└── .vscode\n    ├── c_cpp_properties.json\n    ├── launch.json\n    └── tasks.json\n```\n参考[使用VSCode调试ITensor项目](https://blog.whuzfb.cn/blog/2020/07/04/itensor_vscode/#35-%E7%BC%96%E8%AF%91%E5%92%8C%E8%BF%90%E8%A1%8C)调试代码\n\n## 混乱的文件结构\n如下：  \n```txt\nsimple_cpp\n├── main.cpp\n├── model.cpp\n├── model.h\n├── Makefile\n├── README.md\n├── test.cpp\n└── test.h\n```\n此[Makefile](https://github.com/zfb132/simple_cpp/tree/main/Makefile)文件依然可用，只是为了效率，需要修改头文件[目录](https://github.com/zfb132/simple_cpp/blob/7fb9d08020f99b60c4c83d5fffc9fd8923c2462c/Makefile#L21)（删除原先的`include/`）  \n`INCLUDES = -I $(SRC_PATH)`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzfb132%2Fsimple_cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzfb132%2Fsimple_cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzfb132%2Fsimple_cpp/lists"}