即以此功德,庄严佛净土。上报四重恩,下济三途苦。惟愿见闻者,悉发菩提心。在世富贵全,往生极乐国。

缘起:笔者也是初学者,对于碰到的问题花了整整一个晚上查资料,到现在才调试通过。将遇见的问题和解决方案分享给大家,希望后来的初学者受益!南无阿弥陀佛!

(1)问题1:cl is not a full path and was not found in the PATH

cmake .

-- Building for: NMake Makefiles

-- The C compiler identification is unknown

-- The CXX compiler identification is unknown

CMake Error at CMakeLists.txt:5 (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 at CMakeLists.txt:5 (project):

The CMAKE_CXX_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 "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path

to the compiler, or to the compiler name if it is in the PATH.

解决方法:注意gcc.exe一定要带上exe文件名!

export CC="/d/msys32/mingw32/bin/gcc.exe"       

export CXX="/d/msys32/mingw32/bin/g++.exe"

cmake /path/to/your/project

(2)问题2

$ cmake .

-- Building for: NMake Makefiles

-- The C compiler identification is GNU 5.3.0

-- The CXX compiler identification is GNU 5.3.0

-- Check for working C compiler: D:/msys32/mingw32/bin/gcc.exe

CMake Error: Generator: execution of make failed. Make command was: "nmake" "/NOLOGO" "cmTC_409d1\fast"

-- Check for working C compiler: D:/msys32/mingw32/bin/gcc.exe -- broken

CMake Error at D:/msys32/mingw32/share/cmake-3.4/Modules/CMakeTestCCompiler.cmake:61 (message):

The C compiler "D:/msys32/mingw32/bin/gcc.exe" is not able to compile a

simple test program.

It fails with the following output:

Change Dir: D:/msys32/home/Demo1/CMakeFiles/CMakeTmp

Run Build Command:"nmake" "/NOLOGO" "cmTC_409d1\fast"

系统找不到指定的文件。

Generator: execution of make failed.  Make command was: "nmake" "/NOLOGO"

"cmTC_409d1\fast"

解决方法:

cmake . -G"MSYS Makefiles"

(3) 运行结果

$ cmake . -G"MSYS Makefiles"

-- The C compiler identification is GNU 5.3.0

-- The CXX compiler identification is GNU 5.3.0

-- Check for working C compiler: D:/msys32/mingw32/bin/gcc.exe

-- Check for working C compiler: D:/msys32/mingw32/bin/gcc.exe -- works

-- Detecting C compiler ABI info

-- Detecting C compiler ABI info - done

-- Detecting C compile features

-- Detecting C compile features - done

-- Check for working CXX compiler: D:/msys32/mingw32/bin/g++.exe

-- Check for working CXX compiler: D:/msys32/mingw32/bin/g++.exe -- works

-- Detecting CXX compiler ABI info

-- Detecting CXX compiler ABI info - done

-- Detecting CXX compile features

-- Detecting CXX compile features - done

-- Configuring done

-- Generating done

-- Build files have been written to: D:/msys32/home/Demo2

$ make

Scanning dependencies of target Demo

[ 33%] Building CXX object CMakeFiles/Demo.dir/main.cc.obj

[ 66%] Building CXX object CMakeFiles/Demo.dir/MathFunctions.cc.obj

[100%] Linking CXX executable Demo.exe

[100%] Built target Demo

$ ./demo 3 3

3 ^ 3 is 27

CMake+mingw----无法找到gcc/g++问题相关推荐

  1. Cmake构建_指定gcc/g++版本

    平时我们电脑上可能有多个编译器版本,可以通过设置CMAKE_C_COMPILE和CMAKE_CXX_COMPILER两个变量来设置我们的编译器路径 SET(CMAKE_C_COMPILER " ...

  2. MinGW下载并配置gcc/g++编译环境

    本文将讲解如何下载MinGW并配置gcc\g++编译环境 #方案一:官网下载 ##一.下载MinGW 在MinGW官网中下载"mingw-get-setup.exe" 官网传送门: ...

  3. GCC下载地址(linux/windows\安装)或从minGW中取得gcc

    Linux中自带GCC,或者可以通过包管理器来取得/更新GCC: Windows一般需要自行下载安装GCC,网址如下: 当然,直接下载另一个更容易下载的编译器minGW会更加方便,如果希望使用gcc而 ...

  4. gcc/g++/makefile/easymake/cmake/xmake/nmake ...

    最简单的Makefile,但是还是大程序少不了makefile工具 #CC=arm-linux-gnueabihf- CC= target:     $(CC)gcc -o algo_main alg ...

  5. Linux下gcc/g++、make和cmake的区别

    文本程序到可执行文件生成无论在什么平台大致分为以下几个部分:  1.用编辑器编写源代码,如.c文件.  2.用编译器编译代码生成目标文件,如.o.  3.用链接器连接目标代码生成可执行文件,如.exe ...

  6. Linux下 gcc/g++ 版本切换与CMake各版本安装

    一. gcc/g++ 版本切换 首先下载需要的版本(以gcc8为例) sudo apt-get install gcc-8 删除原有的gcc链接, 改为新链接 cd /usr/bin sudo rm ...

  7. 【Centos 使用rpm离线安装 make cmake gcc g++】

    Centos 使用rpm离线安装 make cmake gcc g++ 缺少 ld 安装 make 安装cmake 安装gcc g++ 参考 linux rpm 软件包地址 https://pkgs. ...

  8. win10 vscode+clangd代码提示+cmake+mingw编译器和调试器

    win10 vscode+clangd代码提示+cmake+mingw编译器和调试器 前言 第一步,把cmake,mingw,llvm-win64安装好 安装好vscode必备的插件 利用cmake构 ...

  9. windows下使用cmake+mingw配置makefile(1)

    转载自:https://blog.csdn.net/xiaopangzi313/article/details/53115702 1.下载Cmake,并配置环境变量 下载链接:https://cmak ...

最新文章

  1. 如果你没用过maven的install,你应该了解一下!maven中的install功能及用法。
  2. China SAFe DAY 2020中国规模化敏捷大会圆满落幕
  3. 溯因推理:人工智能的盲点
  4. 【深入浅出Node.js系列十一】Node.js开发框架Express4.x
  5. 1.4 Matplotlib:绘图
  6. Shell变量:Shell变量的定义、删除变量、只读变量、变量类型
  7. 手机html滚动原理,手机滚动-如何实现惯性滚动
  8. 酒店管理系统-概要设计说明书
  9. matlab除法使用broadcast机制要小心
  10. 身份证编码前六位对应地区(下)
  11. 【附源码】计算机毕业设计SSM汽车租赁系统
  12. 用matlab道路交通信息化,tiaffic 基于matlab十字路口交通流模拟仿真,多种集合 263万源代码下载- www.pudn.com...
  13. 仿今日头条小程序搭建
  14. uniapp字体图标的使用
  15. java怎样断开http请求_http post请求管道断开
  16. c语言何钦铭,C语言 何钦铭
  17. CUT&RUN——检测蛋白-DNA相互作用的强大通用技术
  18. 15.学习Camera之——camera理论基础和工作原理
  19. adb为Android的root方法,Android 实现永久性开启adb 的root权限
  20. in a frame because it set 'X-Frame-Options' to 'sameorigin'.

热门文章

  1. Ovation系列 1X00781H01L 电源模块PDF说明书
  2. 安装 MySQL 2012 (windows 版)
  3. 中国知网系统的结构服务器,中国知网数据库网络版和本地镜像的不同之处
  4. webpack打包html
  5. 【操作系统】多级索引、混合索引例题
  6. centos7.9 配置无线网卡连接wifi
  7. 无线网路不可用(hp4410s)
  8. 小米8 SE官方原版ROM系统MIUI所有固件
  9. 什么是CSS权重值?CSS权重值的优先级是什么?
  10. 第十三届光学与光电子国际学术会议(SOPO 2021)