Sup*_*etz 2 c++ mingw makefile cmake
我正在尝试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)
Run Code Online (Sandbox Code Playgroud)
输出
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"
Run Code Online (Sandbox Code Playgroud)
似乎 GNU 编译器已被识别,但似乎不起作用。任何帮助将非常感激。我试图避免使用 Cygwin ......但几乎准备好在这里一秒钟内走这条路。
为了解决我遇到的问题,我必须做两件事。
cmake -G "MinGW Makefiles" .
(windows 上的大写 -G)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)
Run Code Online (Sandbox Code Playgroud)