Cmake 编译器问题
Cmake Compiler Issue
我正在尝试设置 cmake
使用 Windows 10 使用 MinGW
。我在我的系统路径和环境路径设置中包含了路径 c:/MinGW/bin
。我已经从我的路径中删除了 sh.exe
(不过,如果可能的话,我希望能够保留它)。
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.. 但几乎准备好在一秒钟内走那条路了。
要解决我遇到的问题,我必须做两件事。
- 使用命令
cmake -G "MinGW Makefiles" .
(大写-G on windows)
- 更新我的
CMakeLists.txt
文件以将 gcc 用于 C 编译器,将 g++ 用于 C++ 编译器
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
使用 Windows 10 使用 MinGW
。我在我的系统路径和环境路径设置中包含了路径 c:/MinGW/bin
。我已经从我的路径中删除了 sh.exe
(不过,如果可能的话,我希望能够保留它)。
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.. 但几乎准备好在一秒钟内走那条路了。
要解决我遇到的问题,我必须做两件事。
- 使用命令
cmake -G "MinGW Makefiles" .
(大写-G on windows) - 更新我的
CMakeLists.txt
文件以将 gcc 用于 C 编译器,将 g++ 用于 C++ 编译器
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)