From Mingw-w64, CMake cannot find the non-default compiler I specified on the command line.
This is the pre-build output:
MINGW64 /C/projects/TEST
$ cmake -G "MSYS Makefiles" -D CMAKE_C_COMPILER=/mingw64/bin/gcc -D CMAKE_CXX_COMPILER=/mingw64/bin/g++ ../Test-LineHandler
Sub-project name: Test
-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
CMake Error at CMakeLists.txt:16 (project):
The CMAKE_C_COMPILER:
C:/msys64/mingw64/bin/gcc
is not a full path to an existing compiler tool.
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:16 (project):
The CMAKE_CXX_COMPILER:
C:/msys64/mingw64/bin/g++
is not a full path to an existing compiler tool.
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.
-- Configuring incomplete, errors occurred!
See also "C:/projects/TEST/CMakeFiles/CMakeOutput.log".
However, both gcc
and g++
exist:
$ ls -l C:/msys64/mingw64/bin/gcc
-rwxr-xr-x 1 RFT RFT 2218766 Dec 10 00:50 C:/msys64/mingw64/bin/gcc
$ ls -l C:/msys64/mingw64/bin/g++
-rwxr-xr-x 1 RFT RFT 2221326 Dec 10 00:50 C:/msys64/mingw64/bin/g++
$ ls -l /mingw64/bin/gcc
-rwxr-xr-x 1 RFT RFT 2218766 Dec 10 00:50 /mingw64/bin/gcc
$ ls -l /mingw64/bin/g++
-rwxr-xr-x 1 RFT RFT 2221326 Dec 10 00:50 /mingw64/bin/g++
This is the generated CMakeOutput.log
file:
$ more ./CMakeFiles/CMakeOutput.log
The system is: Windows - 10.0.19041 - AMD64
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: C:/msys64/mingw64/bin/gcc
Build flags:
Id flags:
The output was:
0
Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "a.exe"
The C compiler identification is GNU, found in "C:/projects/TEST/CMakeFiles/3.19.3/CompilerIdC/a.exe"
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: C:/msys64/mingw64/bin/g++
Build flags:
Id flags:
The output was:
0
Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.exe"
The CXX compiler identification is GNU, found in "C:/projects/TEST/CMakeFiles/3.19.3/CompilerIdCXX/a.exe"
Am I specifying the non default compiler correctly on the command line?
The exact error is: C:/msys64/mingw64/bin/gcc is not a full path to an existing compiler tool.
Which is correct as the full path is C:/msys64/mingw64/bin/gcc.exe
.
So just include the .exe
extension of the compiler specified.