[英]how do i set up a project folder in vscode and link all cpp files
i'm new to cpp and just moved to classes, but now im stuck here wondering how do i link 2 or more cpp files to make a project(main.cpp - for main, abc.h - for defining class, abc.cpp- for defining methods outside the class).我是 cpp 的新手,刚开始上课,但现在我想知道如何链接 2 个或多个 cpp 文件来创建项目(main.cpp - 用于 main,abc.h - 用于定义 class,abc.cpp - 用于定义类外的方法)。 For now i use the command
g++ main.cpp abc.cpp -o main
to link all the files but as my project grows larger it will become more tedious to enter all the file names.Some guy here told if i create a project i should be able to compile as usual without compiling manually.So how do i do that in vscode?现在我使用命令
g++ main.cpp abc.cpp -o main
链接所有文件,但是随着我的项目变大,输入所有文件名将变得更加乏味。这里有人告诉我如果我创建一个项目,我应该能够像往常一样编译而无需手动编译。那么我如何在 vscode 中做到这一点?
You should look for the concept of makefile, and especially cmake which will help you for your compilation problem.您应该寻找 makefile 的概念,尤其是 cmake,它将帮助您解决编译问题。
For bigger projects you can use makefile for compiling easily and faster.对于更大的项目,您可以使用 makefile 轻松快速地进行编译。 So in vs code I recommend you to use this extension.
所以在 vs code 中我推荐你使用这个扩展。 VS Code C/C++ Makefile Project
VS Code C/C++ Makefile 项目
Firstly,首先,
C/C++ Make: INIT Project
C/C++ 制作:初始化项目
After,后,
C++ Project
C++项目
In makefile you can customize your settings.在 makefile 中,您可以自定义设置。
Also you can watch this tutorial video to understand easily this process in vs code Debugging Makefile Project with Visual Studio Code您也可以观看本教程视频,以便在 vs 代码中使用 Visual Studio Code 调试 Makefile 项目轻松理解此过程
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.