8

I am getting errors when trying to build nanomsg project in Windows 7:

cmake ..
-- Building for: NMake Makefiles
-- The C compiler identification is GNU 4.7.1
-- Check for working C compiler: C:/Program Files (x86)/CodeBlocks/MinGW/bin/gcc.exe
CMake Error: Generator: execution of make failed. Make command was: "nmake" "/NOLOGO" "cmTC_5d837\fast"
-- Check for working C compiler: C:/Program Files (x86)/CodeBlocks/MinGW/bin/gcc.exe -- broken
CMake Error at C:/Program Files (x86)/cmake-3.9.4-win64-x64/share/cmake-3.9/Modules/CMakeTestCCompiler.cmake:51 (message):
The C compiler "C:/Program Files (x86)/CodeBlocks/MinGW/bin/gcc.exe" is not
able to compile a simple test program.

It fails with the following output:

Change Dir: C:/Users/User/Documents/Internal/nanomsg-master/build/CMakeFiles/CMakeTmp



Run Build Command:"nmake" "/NOLOGO" "cmTC_5d837\fast"



Generator: execution of make failed.  Make command was: "nmake" "/NOLOGO"
"cmTC_5d837\fast"





CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:29 (project)


-- Configuring incomplete, errors occurred!
See also "C:/Users/User/Documents/Internal/nanomsg-master/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/User/Documents/Internal/nanomsg-master/build/CMakeFiles/CMakeError.log".

I use gcc compiler and make from Mingw toolchain and I can run succesfully gcc.exe and mingw32-make.exe on a simple example.

In the file CMakeCache.txt the cache variables are set as follows:

//C compiler
CMAKE_C_COMPILER:FILEPATH=C:/Program Files (x86)/CodeBlocks/MinGW/bin/gcc.exe

//Program used to build from makefiles.
CMAKE_MAKE_PROGRAM:STRING=nmake

I think that the problem comes from CMAKE_MAKE_PROGRAM variable it should take C:/Program Files (x86)/CodeBlocks/MinGW/bin/mingw32-make.exe, however i dont understand from where it gets the value nmake.

Even i replaced it manually I get the same problem.

My questions :

  • How CMake fills the Cache variables ?
  • Why CMAKE_MAKE_PROGRAM takes the value nmake ?
  • Why changing manually this variable didn t solve the problem ?
Cœur
  • 37,241
  • 25
  • 195
  • 267
Mouin
  • 1,025
  • 4
  • 19
  • 33
  • 3
    Possible duplicate of [CMake Error at CMakeLists.txt:30 (project): No CMAKE\_C\_COMPILER could be found](https://stackoverflow.com/questions/32801638/cmake-error-at-cmakelists-txt30-project-no-cmake-c-compiler-could-be-found). You need to specify a generator in CMake command line like `-G "MinGW Makefiles"` and - depending on how many compilers you have installed - also the full paths to the compilers. – Florian Oct 18 '17 at 10:29
  • @Florian, Thank you for the feedback, OK that resolves the problem :). Just what happened when I changed the generator does CMake has internal scripts that searches for the c compiler and make program and then updates the cache variables because now I can see that the variables have good values in CMakeCache.txt – Mouin Oct 18 '17 at 13:42
  • 1
    @Mouin - `nmake` is Microsoft's make tool. You can get a copy of it from the [Visual C++ 2015 Build Tools](http://landinghub.visualstudio.com/visual-cpp-build-tools). You no longer need to download Visual Studio or deal with the expiring trials. The Build Tools are a subset of the Visual Studio tools, and it include a compiler, linker, nmake, and a few other essential tools for Windows. – jww Oct 30 '17 at 22:35

1 Answers1

6

CMake fills the cache file with the values it detects based what is in CMakeLists.txt and whatever files it includes in combination with any -D paramters supplied to cmake.

On Windows CMake will default to Microsoft's nmake tool. The way to override this is by passing parameter -G"MinGW Makefiles" to cmake, or in case you use MSYS shell -G"MSYS Makefiles".

But there is a faster build tool than make called Ninja (get it from https://ninja-build.org/) which you can use by passing -GNinja to cmake.

Note: I see you're using the old MinGW that comes with Code::Blocks. There is a more up to date successor to MinGW called MinGW-w64, which supports both Windows 32-bit and 64-bit. A recent standalone build can be downloaded from https://winlibs.com/ and it also includes ninja.exe.

P.S.: If you run into more issues building the nanomsg sources after following these tips, consider passing -DNN_TESTS:BOOL=OFF to cmake

Brecht Sanders
  • 6,215
  • 1
  • 16
  • 40