Hi,
I have a thresh msys2 install with mingw64 packages for cmake and gcc.
The compiler is working in standalone (gcc hello.cpp -o hello
) but it does not work anymore with cmake.
Here is my command line from a build directory at the same level as my CMakeLists.txt:
cmake --debug-trycompile .. -G "MinGW Makefiles" -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc
And it is failing with:
debug trycompile on
– The C compiler identification is unknown
– The CXX compiler identification is unknown
– Detecting C compiler ABI info
CMake Debug Log at […]/msys64/mingw64/share/cmake/Modules/CMakeDetermineCompilerABI.cmake:57 (try_compile):
Executing try_compile (CMAKE_C_ABI_COMPILED) in:
[…]/build/Release/CMakeFiles/CMakeScratch/TryCompile-41abgu
Call Stack (most recent call first):
[…]/msys64/mingw64/share/cmake/Modules/CMakeTestCCompiler.cmake:26 (CMAKE_DETERMINE_COMPILER_ABI)
CMakeLists.txt:47 (project)
– Detecting C compiler ABI info - failed
– Check for working C compiler: […]/msys64/ucrt64/bin/gcc.exe
CMake Debug Log at […]/msys64/mingw64/share/cmake/Modules/CMakeTestCCompiler.cmake:56 (try_compile):
Executing try_compile (CMAKE_C_COMPILER_WORKS) in:
[…]/build/Release/CMakeFiles/CMakeScratch/TryCompile-dsx3w6
Call Stack (most recent call first):
CMakeLists.txt:47 (project)
– Check for working C compiler: […]/msys64/ucrt64/bin/gcc.exe - broken
CMake Error at […]/msys64/mingw64/share/cmake/Modules/CMakeTestCCompiler.cmake:67 (message):
The C compiler
“[…]/msys64/ucrt64/bin/gcc.exe”
is not able to compile a simple test program.
It fails with the following output:
Change Dir: ‘[…]/build/Release/CMakeFiles/CMakeScratch/TryCompile-dsx3w6’
Run Build Command(s): […]/msys64/mingw64/bin/cmake.exe -E env VERBOSE=1 […]/msys64/ucrt64/bin/mingw32-make.exe -f Makefile cmTC_ecb19/fast
[…]/msys64/ucrt64/bin/mingw32-make.exe -f CMakeFiles\cmTC_ecb19.dir\build.make CMakeFiles/cmTC_ecb19.dir/build
mingw32-make[1]: Entering directory ‘[…]/build/CMakeFiles/CMakeScratch/TryCompile-dsx3w6’
Building C object CMakeFiles/cmTC_ecb19.dir/testCCompiler.c.obj
[…]\msys64\ucrt64\bin\gcc.exe -o CMakeFiles\cmTC_ecb19.dir\testCCompiler.c.obj -c […]/build\Release\CMakeFiles\CMakeScratch\TryCompile-dsx3w6\testCCompiler.c
mingw32-make[1]: *** [CMakeFiles\cmTC_ecb19.dir\build.make:77: CMakeFiles/cmTC_ecb19.dir/testCCompiler.c.obj] Error 1
mingw32-make[1]: Leaving directory ‘[…]/build/CMakeFiles/CMakeScratch/TryCompile-dsx3w6’
mingw32-make: *** [Makefile:126: cmTC_ecb19/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:47 (project)
– Configuring incomplete, errors occurred!
I’ve seen lots of post on the web with similar issues but I’ve never found a solution.
NB I previously installed gcc directly from a mingw64 installation, cmake was installed manually, and it worked.
NB the issue is now the same with the original cmake install or the msys2 one.
NB msys2 was installed without admin rights, user env path has been updated to find gcc and cmake