在windows下使⽤Vscode⽤CMake..命令编译源代码时候遇到
的问题之解决办法
由于我在windows下⽤Vscode总是不记得如何deal这个错误,因此今天就⽤这篇博客记录下来!
在windows的Vscode这个IDE下,打开终端,输⼊命令⾏:
C:\Users\11602\Desktop\test\build> cmake ..
报错:
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error :3 (project):
The CMAKE_C_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C++, cmake must be run from a shell
that can use the compiler cl from the command line.  This environment is
unable to invoke the cl compiler.  To fix this problem, run cmake from the
Visual Studio Command Prompt (vcvarsall.bat).
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
CMake Error :3 (project):
The CMAKE_CXX_COMPILER:
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C++, cmake must be run from a shell
that can use the compiler cl from the command line.  This environment is
unable to invoke the cl compiler.  To fix this problem, run cmake from the
Visual Studio Command Prompt (vcvarsall.bat).
原因:我没有选择GCC作为我的编译器!(因为我windows下还有别的VS的编译器)
deal办法:
①先在Vscode下⽤键盘按下ctrl + shift + p,再选择CMake:Configure
②选择GCC作为我的编译器
③最后再⽤CMake..和mingw命令(windows)编译代码即可成功运⾏!
(linux下则是⽤CMake..和make命令(linux)配合来编译代码的)
在linxu,下
出现问题:cmake如何使用
make: *** No targets specified and no makefile found.  Stop.
原因:也是因为没有在Vscode下设置gcc为默认编译器!(同windows下的问题)
deal⽅法:按照上述步骤,ctrl + shift + p ,然后输⼊cmake configure ,然后选择gcc作为编译器即可!

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。