(1)window端vscode使用cmake编译,多文件编译(2)使用途中cmake ..报错

发布于:2023-01-19 ⋅ 阅读:(1985) ⋅ 点赞:(1)

先写一下参考的大佬文章网址

VSCode配置C++环境(Windows篇) | 爱编程的大丙

其中我操作后出现以下问题

  问题: cmake ..没有指定到相应的编译环境,报错

        我在上述文章中使用到cmake ..指令后,无法看到视频中的效果,因为Makefile就生成好的,就手贱把bulid文件删掉,其中我卸载好几次vscode并删除vscode的各种文件,操作时还是这样一个界面

注:bulid被删除啦就直接 mkdir build,cd bulid ,cmake .. 就可以生成bulid文件中的东西(使用cmake -G "MinGW Makefiles" ..指令只是指定好编译环境,linux也会在指令上有点差别)

使用        cmake -G "MinGW Makefiles" .. 指令的时候现象不一,出现下面的错误

CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
CMake Warning (dev) in CMakeLists.txt:
  No cmake_minimum_required command is present.  A line of code such as

    cmake_minimum_required(VERSION 3.15)

  should be added at the top of the file.  The version specified may be lower
  if you wish to support older CMake versions for this project.  For more
  information run "cmake --help-policy CMP0000".
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring incomplete, errors occurred!

在纠结一上午后,我注意到这个

 cmake ..时指向的是nmake Makefiles 我需要的是指向MinGw Makefiles ,相应的使用指令没用,就想起来前面在配置gcc编译的时候把 mingw32-make.exe 改成啦make.exe,方便直接make就可以生成Makefile,就这偷懒一下(也是有篇文章说可以改就改啦),就导致我无法指定MinGw Makefiles生成Makefile,所以后面把make.exe改回去就行

注:bulid被删除啦就直接 mkdir build,cd bulid ,cmake .. 就可以生成bulid文件中的东西(使用cmake -G "MinGW Makefiles" ..指令只是指定好编译环境,linux也会在指令上有点差别)

 改完之后就ok啦

希望给大家一点帮助,并做个笔记,其他的在大佬的网址和B站视频都讲的很好


网站公告

今日签到

点亮在社区的每一天
去签到