using cmake with mingw-w64 error compiling test program - gcc

I'm trying to do a simple compilation with mingw-w64 and cmake. But for some reason I can't. It fails verifying if gcc can compile a C program which is weird. Any ideas?
Thanks
Paulo
C:\work\opencv\myown\hello>cmake -DCMAKE_CXX_COMPILER=g++ -DCMAKE_CC_COMPILER=gcc
-- The C compiler identification is GNU 5.3.0
-- The CXX compiler identification is GNU 5.3.0
-- Check for working C compiler: C:/Program Files/mingw-w64/x86_64-5.3.0-win32-seh-rt_v4-rev0/mingw64/bin/gcc.exe
CMake Error: Generator: execution of make failed. Make command was: "nmake" "/NOLOGO" "cmTC_8ce25\fast"
-- Check for working C compiler: C:/Program Files/mingw-w64/x86_64-5.3.0-win32-seh-rt_v4-rev0/mingw64/bin/gcc.exe -- broken
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.5/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "C:/Program
Files/mingw-w64/x86_64-5.3.0-win32-seh-rt_v4-rev0/mingw64/bin/gcc.exe" is
not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/work/opencv/myown/hello/CMakeFiles/CMakeTmp
Run Build Command:"nmake" "/NOLOGO" "cmTC_8ce25\fast"
Generator: execution of make failed. Make command was: "nmake" "/NOLOGO"
"cmTC_8ce25\fast"
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:7 (project)
-- Configuring incomplete, errors occurred!
See also "C:/work/opencv/myown/hello/CMakeFiles/CMakeOutput.log".
See also "C:/work/opencv/myown/hello/CMakeFiles/CMakeError.log".

Is nmake available in your PATH?
You can provide another make command using CMAKE_MAKE_PROGRAM, like for instance:
cmake -DCMAKE_CXX_COMPILER=g++ -DCMAKE_CC_COMPILER=gcc -DCMAKE_MAKE_PROGRAM=mingw32-make

Related

Assimp Compilation Error Using CMake: GCC Cannot Compile Test Program

I am trying to compile Assimp 5.0.1 for Windows 10 using CMake. The C/C++ compilers I have through MinGW are GCC and G++. If I understand the problem correctly, there is an issue with the MakeFile's whitespace somewhere. The /CMakeTmp/ directory is empty, and I am sure the answer is right in front of me somewhere:
Console Output:
-- The C compiler identification is GNU 9.2.0
-- The CXX compiler identification is GNU 9.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe - broken
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.20/Modules/CMakeTestCCompiler.cmake:66 (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: Q:/programming/westy/src/lib/assimp-5.0.1/build/CMakeFiles/CMakeTmp
Run Build Command(s):make -f Makefile /nologo cmTC_a4ec5\fast && Makefile:37: *** missing separator. Stop.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:54 (PROJECT)
-- Configuring incomplete, errors occurred!
See also "Q:/programming/westy/src/lib/assimp-5.0.1/build/CMakeFiles/CMakeOutput.log".
See also "Q:/programming/westy/src/lib/assimp-5.0.1/build/CMakeFiles/CMakeError.log".
CMakeError.log:
Detecting C compiler ABI info failed to compile with the following output:
Change Dir: Q:/programming/westy/src/lib/assimp-5.0.1/build/CMakeFiles/CMakeTmp
Run Build Command(s):make -f Makefile /nologo cmTC_165dc\fast && Makefile:37: *** missing separator. Stop.
CMakeOutput.log:
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: C:/MinGW/bin/gcc.exe
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 "Q:/programming/westy/src/lib/assimp-5.0.1/build/CMakeFiles/3.20.2/CompilerIdC/a.exe"
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: C:/MinGW/bin/g++.exe
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 "Q:/programming/westy/src/lib/assimp-5.0.1/build/CMakeFiles/3.20.2/CompilerIdCXX/a.exe"
Which -G option did you use for cmake?
The /nologo parameter for make doesn't seem right, that looks like a Microsoft/MSVC parameter. If you didn't specify -G then CMake defaults to -G"NMake Makefiles" on Windows.
Make sure to use cmake flag -G"MinGW Makefiles" for mingw32-make or -G"MSYS Makefiles" if you use MSYS' make.
But to avoid all those make issues and improve speed -GNinja is the best solution, provided you have Ninja available (see https://ninja-build.org/).
Finally, you're still on MinGW GCC 9.2.0. Newer versions are available, see http://winlibs.com/ for standalone builds which also come with newer mingw32-make.

Set Clion on Windows 10

I was configuring Clion by following a guide here on StackOverflow, but I have a problem. The section about make, C compiler, and C++ compiler have some problems, but I don't understand what I should do.
Notice the "Test CMake run finished with error" message. When I click on "more...", I see this:
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Warning at /cygdrive/c/Users/SpeedHunter/.CLion2018.1/system/cygwin_cmake/share/cmake-3.10.3/Modules/Platform/CYGWIN.cmake:15 (message):
CMake no longer defines WIN32 on Cygwin!
(1) If you are just trying to build this project, ignore this warning or
quiet it by setting CMAKE_LEGACY_CYGWIN_WIN32=0 in your environment or in
the CMake cache. If later configuration or build errors occur then this
project may have been written under the assumption that Cygwin is WIN32.
In that case, set CMAKE_LEGACY_CYGWIN_WIN32=1 instead.
(2) If you are developing this project, add the line
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
at the top of your top-level CMakeLists.txt file or set the minimum
required version of CMake to 2.8.4 or higher. Then teach your project to
build on Cygwin without WIN32.
Call Stack (most recent call first):
/cygdrive/c/Users/SpeedHunter/.CLion2018.1/system/cygwin_cmake/share/cmake-3.10.3/Modules/CMakeSystemSpecificInformation.cmake:26 (include)
CMakeLists.txt:1 (project)
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- broken
CMake Error at /cygdrive/c/Users/SpeedHunter/.CLion2018.1/system/cygwin_cmake/share/cmake-3.10.3/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler
"/usr/bin/cc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /cygdrive/c/Users/SpeedHunter/AppData/Local/Temp/cmake_check_environment/_build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make.exe" "cmTC_4ca12/fast"
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:1 (project)
-- Configuring incomplete, errors occurred!
See also "/cygdrive/c/Users/SpeedHunter/AppData/Local/Temp/cmake_check_environment/_build/CMakeFiles/CMakeOutput.log".
See also "/cygdrive/c/Users/SpeedHunter/AppData/Local/Temp/cmake_check_environment/_build/CMakeFiles/CMakeError.log".
Error code: 1
What should I do?

Caffe Build Error in Windows 10

I'm trying to build Caffe in Windows 10 following instructions here. I have installed all the prerequisites and dependencies. But I'm getting following error.
-- The C compiler identification is unknown
-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-
3.9/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:/Caffe/caffe/build/CMakeFiles/CMakeTmp
Run Build Command:"C:/Ninja/ninja.exe" "cmTC_6595e"
[1/2] Building C object CMakeFiles\cmTC_6595e.dir\testCCompiler.c.obj
FAILED: CMakeFiles/cmTC_6595e.dir/testCCompiler.c.obj
C:\MinGW\bin\gcc.exe -o CMakeFiles\cmTC_6595e.dir\testCCompiler.c.obj -c
testCCompiler.c
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:18 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Caffe/caffe/build/CMakeFiles/CMakeOutput.log".
See also "C:/Caffe/caffe/build/CMakeFiles/CMakeError.log".
ERROR: Configure failed
Caffe Build Error
I searched for a solution and tried different things but nothing could solve the problem. Any help with this regard is highly appreciated.
Thanks in advance!
I finally figured it out. It was a problem with the C Compiler in my computer - gcc. I reinstalled the compiler and following two lines to CMakeList.txt file according to this solution,
set(CMAKE_C_COMPILER "C:/MinGW/bin/gcc.exe")
set(CMAKE_CXX_COMPILER "C:/MinGW/bin/g++.exe")

Can't run Cmake on windows with MinGW and git bash

I try to build gitql.
I've installed go, CMake and MinGW, and tried to make them work under git bash, but when I call cmake in gitql directory I get this error:
-- Building for: NMake Makefiles
-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:14 (PROJECT):
The CMAKE_C_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C++, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt (vcvarsall.bat).
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.
-- Configuring incomplete, errors occurred!
See also "C:/Go/src/github.com/cloudson/gitql/libgit2/CMakeFiles/CMakeOutput.log".
See also "C:/Go/src/github.com/cloudson/gitql/libgit2/CMakeFiles/CMakeError.log".
make: *** [prepare] B▒▒d 1
So I've tried to point to gcc from mingw using:
export CC=/c/MinGW/bin/gcc.exe
and when I run make I get this error:
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
CMake Error: Generator: execution of make failed. Make command was: "nmake" "/NOLOGO" "cmTC_14ff0\fast"
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.7/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:/Go/src/github.com/cloudson/gitql/libgit2/CMakeFiles/CMakeTmp
Run Build Command:"nmake" "/NOLOGO" "cmTC_14ff0\fast"
Generator: execution of make failed. Make command was: "nmake" "/NOLOGO"
"cmTC_14ff0\fast"
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:14 (PROJECT)
-- Configuring incomplete, errors occurred!
See also "C:/Go/src/github.com/cloudson/gitql/libgit2/CMakeFiles/CMakeOutput.log".
See also "C:/Go/src/github.com/cloudson/gitql/libgit2/CMakeFiles/CMakeError.log".
make: *** [prepare] B▒▒d 1
How can I inform cmake to use make instead of nmake? I have make installed in C:\Program Files (x86)\GnuWin32\bin which is in $PATH.
I've also try to call cmake -G "MinGW Makefiles" but I've got this error:
CMake Error: The source directory "C:/Go/src/github.com/cloudson/gitql" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
cmake -G "MinGW Makefiles" is effectively the right command to inform CMake you want to use MinGW.
To be complete, you should create a separate folder, let's call it build, and call cmake from it to make an out-of-source build:
cd /path/to/build
cmake -G "MinGW Makefiles" /path/to/CMakeLists.txt
The problem here is gitql doesn't provide any CMakeLists.txt file in the repository, so you just can't use CMake to build it, unless you create your own project file. You can try from the given Makefile, and propose it as a pull request.

CMake with MinGW and Eclipse CDT

I'm trying to compile OpenCV with Cmake on Windows 7 (64-bit). It is to be used with Eclipse and CDT, for which I read somewhere that youhave to specify Unix Makefiles regardless of the compiler.
Now, given that I have cygwin as well (for Android NDK stuff), I first tried using its compilers, and I successfully configure CMake and generate makefiles, but only get to 63% of compiling, when OpenCV spits an error (about ffmpeg and HMODULE). So I switched to MinGW (HelloWorld with it was also a pain, I had to specify a full path to MinGW g++ regardless of the PATH variable setting), but now I cannot even configure CMake. I get the following error:
The C compiler identification is GNU
The CXX compiler identification is GNU
CMake Error: your RC compiler: "CMAKE_RC_COMPILER-NOTFOUND" was not found. Please set CMAKE_RC_COMPILER to a valid compiler path or name.
Check for working C compiler: C:/MinGW/bin/gcc.exe
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeRCInformation.cmake:22 (GET_FILENAME_COMPONENT):
get_filename_component called with incorrect number of arguments
Call Stack (most recent call first):
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/Platform/Windows-GNU.cmake:59 (enable_language)
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/Platform/Windows-GNU-C.cmake:1 (include)
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeCInformation.cmake:56 (INCLUDE)
CMakeLists.txt:2 (PROJECT)
CMake Error: CMAKE_RC_COMPILER not set, after EnableLanguage
CMake Error: Internal CMake error, TryCompile configure of cmake failed
Check for working C compiler: C:/MinGW/bin/gcc.exe -- broken
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE):
The C compiler "C:/MinGW/bin/gcc.exe" is not able to compile a simple test program.
It fails with the following output:
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:47 (project)
Configuring incomplete, errors occurred!
If anyone has any idea what might be a problem (conflict with cygwin shell?), I'd appreciate any input. Thanks in advance!
We ran into the same problem with the "Unix Makefiles" Generator. We solved it by using the "MSYS Makefiles" generator (Msys is a shell environment around MinGW, like [a very small] cygwin).
This error message text:
CMake Error: your RC compiler: "CMAKE_RC_COMPILER-NOTFOUND" was not found.
Please set CMAKE_RC_COMPILER to a valid compiler path or name.
indicates that "windres" (for mingw and cygwin gcc-based build trees) is not in the PATH.
windres support, to compile Windows resource (*.rc) files was recently added in CMake 2.8.4. Perhaps windres is not available in your MinGW environment?

Resources