CMake+mingw----无法找到gcc/g++问题
即以此功德,庄严佛净土。上报四重恩,下济三途苦。惟愿见闻者,悉发菩提心。在世富贵全,往生极乐国。
缘起:笔者也是初学者,对于碰到的问题花了整整一个晚上查资料,到现在才调试通过。将遇见的问题和解决方案分享给大家,希望后来的初学者受益!南无阿弥陀佛!
(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++问题相关推荐
- Cmake构建_指定gcc/g++版本
平时我们电脑上可能有多个编译器版本,可以通过设置CMAKE_C_COMPILE和CMAKE_CXX_COMPILER两个变量来设置我们的编译器路径 SET(CMAKE_C_COMPILER " ...
- MinGW下载并配置gcc/g++编译环境
本文将讲解如何下载MinGW并配置gcc\g++编译环境 #方案一:官网下载 ##一.下载MinGW 在MinGW官网中下载"mingw-get-setup.exe" 官网传送门: ...
- GCC下载地址(linux/windows\安装)或从minGW中取得gcc
Linux中自带GCC,或者可以通过包管理器来取得/更新GCC: Windows一般需要自行下载安装GCC,网址如下: 当然,直接下载另一个更容易下载的编译器minGW会更加方便,如果希望使用gcc而 ...
- gcc/g++/makefile/easymake/cmake/xmake/nmake ...
最简单的Makefile,但是还是大程序少不了makefile工具 #CC=arm-linux-gnueabihf- CC= target: $(CC)gcc -o algo_main alg ...
- Linux下gcc/g++、make和cmake的区别
文本程序到可执行文件生成无论在什么平台大致分为以下几个部分: 1.用编辑器编写源代码,如.c文件. 2.用编译器编译代码生成目标文件,如.o. 3.用链接器连接目标代码生成可执行文件,如.exe ...
- Linux下 gcc/g++ 版本切换与CMake各版本安装
一. gcc/g++ 版本切换 首先下载需要的版本(以gcc8为例) sudo apt-get install gcc-8 删除原有的gcc链接, 改为新链接 cd /usr/bin sudo rm ...
- 【Centos 使用rpm离线安装 make cmake gcc g++】
Centos 使用rpm离线安装 make cmake gcc g++ 缺少 ld 安装 make 安装cmake 安装gcc g++ 参考 linux rpm 软件包地址 https://pkgs. ...
- win10 vscode+clangd代码提示+cmake+mingw编译器和调试器
win10 vscode+clangd代码提示+cmake+mingw编译器和调试器 前言 第一步,把cmake,mingw,llvm-win64安装好 安装好vscode必备的插件 利用cmake构 ...
- windows下使用cmake+mingw配置makefile(1)
转载自:https://blog.csdn.net/xiaopangzi313/article/details/53115702 1.下载Cmake,并配置环境变量 下载链接:https://cmak ...
最新文章
- 如果你没用过maven的install,你应该了解一下!maven中的install功能及用法。
- China SAFe DAY 2020中国规模化敏捷大会圆满落幕
- 溯因推理:人工智能的盲点
- 【深入浅出Node.js系列十一】Node.js开发框架Express4.x
- 1.4 Matplotlib:绘图
- Shell变量:Shell变量的定义、删除变量、只读变量、变量类型
- 手机html滚动原理,手机滚动-如何实现惯性滚动
- 酒店管理系统-概要设计说明书
- matlab除法使用broadcast机制要小心
- 身份证编码前六位对应地区(下)
- 【附源码】计算机毕业设计SSM汽车租赁系统
- 用matlab道路交通信息化,tiaffic 基于matlab十字路口交通流模拟仿真,多种集合 263万源代码下载- www.pudn.com...
- 仿今日头条小程序搭建
- uniapp字体图标的使用
- java怎样断开http请求_http post请求管道断开
- c语言何钦铭,C语言 何钦铭
- CUT&RUN——检测蛋白-DNA相互作用的强大通用技术
- 15.学习Camera之——camera理论基础和工作原理
- adb为Android的root方法,Android 实现永久性开启adb 的root权限
- in a frame because it set 'X-Frame-Options' to 'sameorigin'.