0. Make sure GCC is installed, if not, sudo apt-get install gcc
1. Download vscode and install it, it is recommended to deb package
2. Open vscode, install the extension,
Among them, C/C++ is required, and C/C++ support is provided
Code Runner must be installed, providing a running environment for compiled programs
C/C++ Snippets suggests to provide some commonly used C/C++ snippets, such as for(;;){}, it is convenient to write code after installation (tip. If you want to add your own code snippets, you can click the gear in the lower left corner -> User snippets )
EPITECH C/C++ Headers Add headers (including author, creation and modification dates, etc.) to C/C++ files, and add anti-duplication macros to .h header files
File Templates file templates, you can add file templates yourself
GBKtoUTF8 Convert GBK encoded files to UTF-8
Include Autocomplete header file auto-completion
One Dark Pro A nice looking vscode theme
Easy C++ projects provide a simple compilation mode. After opening, you can compile and run directly as long as the C/C++ extension is installed. It is recommended not to use it because you cannot configure the parameters yourself.
3. At this time, the running file has been compiled but cannot be debugged
4. Configure Code Runner settings, find settings, search for Code Runner, find
Edit and modify it to the command you want to execute when the build is running, and attach my favorite here (the output file is named filename. and c++ are one line each, because of display problems I added new lines
5. Configure debug debugging
Go to debug tab, add configuration, select C++ (GDB/LLDB)
此时,新建了一个名为launch.json的json文件,根据你的习惯修改
一项,这里指向要调试的程序//标注:${workspaceFolder}为工作空间文件夹,${fileBasenameNoExtension}为当前打开的文件的文件名,不包括路径和后缀名
添加一项参数(注意不要落下逗号),这指的是在调试前要预先执行的任务(因为如果要使用gdb调试需要在编译时添加-g参数,所以不能直接使用运行时的文件,建议两个可执行文件分开命名)
"preLaunchTask": "build",
按F5调试一次,会提示没有找不到"build",点击配置任务,使用tasks.json模板新建一个Others任务
参数label修改为build,根据需要修改编译时使用的command,记得带上-g参数
每次调试时选中要调试的文件然后按F5就可以愉快的调试了
tips.0.如果创建多个文件的project,建议使用makefile编译和调试
1.设置常用且好记的快捷键会极大的提高工作效率