Cmake编译器问题 [英] Cmake Compiler Issue
问题描述
我正在尝试使用Windows 10和MinGW
设置cmake
.我已经在系统路径和环境路径设置中包含了路径c:/MinGW/bin
.我已经从路径中删除了sh.exe
(尽管,我希望能够保留它).
I am trying to setup cmake
using Windows 10 using MinGW
. I have included the path c:/MinGW/bin
in my system path and environment path settings. I have removed sh.exe
from my path (although, i would love to be able to keep this if possible).
CMakeLists.txt
CMakeLists.txt
cmake_minimum_required(VERSION 3.8)
set(CMAKE_C_COMPILER "C:/MinGW/bin/gcc.exe")
set(CMAKE_CXX_COMPILER "C:/MinGW/bin/gcc.exe")
project (Tutorial)
add_executable(Tutorial tutorial.cpp)
输出
C:\School\athabascua\data structures\ass1>cmake -g "MinGW Makefiles" .
-- The C compiler identification is GNU 5.3.0
-- The CXX compiler identification is GNU 5.3.0
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
CMake Error: Generator: execution of make failed. Make command was: "nmake" "/NOLOGO" "cmTC_b3144\fast"
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.8/Modules/CMakeTestCCompiler.cmake:51 (message):
The C compiler "C:/MinGW/bin/gcc.exe" is not able to compile a simple test
program.
It fails with the following output:
Change Dir: C:/School/athabascua/data structures/ass1/CMakeFiles/CMakeTmp
Run Build Command:"nmake" "/NOLOGO" "cmTC_b3144\fast"
Generator: execution of make failed. Make command was: "nmake" "/NOLOGO"
"cmTC_b3144\fast"
似乎已识别出GNU编译器,但似乎不起作用.任何帮助将非常感激.我正试图避免使用Cygwin ..但几乎准备在几秒钟内走完那条路线.
It seems that the GNU compilers are identified but don't seem to work. Any help would be much appreciated. I am trying to avoid using Cygwin.. but almost ready to go that route in a sec here.
推荐答案
要解决我遇到的问题,我必须做两件事.
To fix the problem I was having, I had to do two things.
- 使用命令
cmake -G "MinGW Makefiles" .
(在Windows上为大写-G) - 更新我的
CMakeLists.txt
文件以将gcc用于C编译器,将g ++用于C ++编译器
- use the command
cmake -G "MinGW Makefiles" .
(capital -G on windows) - update my
CMakeLists.txt
file to use gcc for C compiler and g++ for C++ compiler
CMakeLists.txt
CMakeLists.txt
cmake_minimum_required(VERSION 3.8)
set(CMAKE_C_COMPILER "C:/MinGW/bin/gcc.exe")
set(CMAKE_CXX_COMPILER "C:/MinGW/bin/g++.exe")
project (Tutorial)
add_executable(Tutorial tutorial.cpp)
这篇关于Cmake编译器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!