5

I am trying to install on my windows desktop, a software suite called NUPACK which is used to design nucleic acid reaction pathways. http://www.nupack.org/

This software requires CMake to install, and from my understanding, CMake does not have compilers by itself, and requires us to have compilers separately installed. As such, I downloaded MinGW to use as a C++ compiler. Prior to running, I have set the environment variables of both CMake and MinGW's bin. I am running CMake (version 3.11.1) through the command prompt but I keep encountering the following problem:

C:\Users\Nicholas\Documents\nupack\build>Cmake -DCMAKE_INSTALL_PREFIX=NUPACKINSTALL -G "MinGW Makefiles" ..
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- 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.11/Modules/CMakeTestCCompiler.cmake:52 (message):
  The C compiler

    "C:/MinGW/bin/gcc.exe"

  is not able to compile a simple test program.

I'm guessing CMake cannot identify my MinGW gcc and gcc++ compilers somehow. I tried the following next, but the same error arose.

set CMAKE_C_COMPILER=%C:\mingw\bin\gcc%
set CMAKE_CXX_COMPILER=%C:\mingw\bin\g++%

Has anyone encountered the same problem? Can this be resolved by using MinGW64? I am using Windows 10 and previously, I tried using visual studio 2017's compilers, but it had its on set of problems too.

zizzard
  • 51
  • 1
  • 1
  • 2
  • The reason why it failed can be found in `CMakeFiles\CMakeError.log` – Florian May 15 '18 at 08:40
  • I had the same problem when trying to build LuaDist. Very confusing that cmake prints the full path to gcc, but then isn't able to find it (unless it's due to the forward slashes). – Jesper Matthiesen Nov 04 '18 at 22:27

2 Answers2

6

Yes, the problem is that CMake cannot find GCC compiler. Before be sure that g++ and gcc are installed. It can be MinGW64 or Cygwin.

There are at least three ways to link GCC compiler.

1st way:

Set compilers in CMakeLists.txt:

set(CMAKE_C_COMPILER C:\path\to\gcc.exe)
set(CMAKE_CXX_COMPILER C:\path\to\g++.exe)

2nd way:

When calling cmake in terminal or cmd:

cmake -DCMAKE_C_COMPILER="C:\path\to\gcc.exe" -DCMAKE_CXX_COMPILER="C:\path\to\g++.exe"

3rd way:

Set as environment variable: Go to Windows "Environment Variables" and add to PATH this:

;C:\path_to_MinGW_or_Cygwin\bin
Ugnius Malūkas
  • 2,649
  • 7
  • 29
  • 42
  • Hi Ugnius, thanks for the advice! Just to check, is the older version of MinGW incompatible? I have been using MinGW all this while (the non 64-bit version). Could the error have happened because I was not using MinGW64? – zizzard May 16 '18 at 08:50
  • 64-bit or 32-bit version shouldn't be a problem. I suggest you to use MinGW or Cygwin toolchains. Then use compilers from chosen toolchain. And after you shoud add a path to `bin` folder of toolchain in Environment Variables. – Ugnius Malūkas May 16 '18 at 09:02
  • I'm trying 1,2, and 3 when compiling Google test and it's not working. For (1) and (2) I get an `Invalid escape sequence \m` when parsing `C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin\gcc.exe`error. For (3), when calling CMake with `cmake CMakeLists.txt -DCMAKE_MAKE_PROGRAM=mingw32-make.exe -G "MinGW Makefiles"`, I get an broken compiler error. – Leonardo Nov 08 '19 at 18:31
  • Could you try to run just CMake without defining make? And then when CMake will generate file run `make`? – Ugnius Malūkas Nov 09 '19 at 14:59
0

I had similar problem. My Setup was : VSCode (Windows 10) + GCC 9.2xx + CMake 3.18.2 Environment variables were already set to point to GCC and CMake.

This Worked: https://stackoverflow.com/a/4101496/2865353 Needs to cleanup CMakeCache.txt and CMakeFiles directory.

Erros it fixed are:

-- Building for: NMake Makefiles
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:3 (project):
  The CMAKE_C_COMPILER:
    cl
  is not a full path and was not found in the PATH.

CMake Error at CMakeLists.txt:3 (project):
The CMAKE_CXX_COMPILER:
    cl
is not a full path and was not found in the PATH.