天天看点

VScode(C/C++)自动生成launch.json+cmake断点调试

VScode(C/C++)自动生成launch.json+cmake断点调试

问题1:VScode 最新版本1.12.4不能自动生成launch.json和task.json文件

解决办法:

VScode(C/C++)自动生成launch.json+cmake断点调试

编辑好main.cpp文件,点击“F5”,就会自动生成launch.json和task.json文件,完成编译,输出结果。

问题2:接下来,使用cmake指令编译时,报错:

CMake Deprecation Warning at CMakeLists.txt:12 (cmake_minimum_required):

Compatibility with CMake < 2.8.12 will be removed from a future version of

CMake.

Update the VERSION argument value or use a … suffix to tell

CMake that the project does not need compatibility with older versions.

CMake Error at CMakeLists.txt:14 (project):

Running

‘nmake’ ‘-?’

failed with:

系统找不到指定的文件。

CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage

CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage

– Configuring incomplete, errors occurred!

See also “E:/software_cpp/test_launch.json/build/CMakeFiles/CMakeOutput.log”.

解决方法:

第一步,在根目录确保已经编辑好CMakeLists.txt,然后点击VSCODE最下方 CMake:[debug],

VScode(C/C++)自动生成launch.json+cmake断点调试
VScode(C/C++)自动生成launch.json+cmake断点调试
VScode(C/C++)自动生成launch.json+cmake断点调试

然后点击最下方 “Build”,就会在build文件夹下生成main.exe;

或者直接在 “终端”中 输入 “make”,也会在build文件夹下生成main.exe;

继续阅读