Alternative: Install Windows Subsystem for Linux
The GNU compilers, make and Cmake are easily available for native Windows, as follows:
- Download MinGW-w64 compiler (gcc, g++ gfortran)
This also installs GNU
c:\mingw\binto your PATH under Control Panel → System → Advanced.
- For convenience, symlink
cd C:\mingw\bin mklink make.exe mingw32-make.exe
CMake on Windows
CMake on Windows has a
Within the project code directory, in general build programs that have
CMakeLists.txt on Windows (and other operating systems) with:
cmake -G "MinGW Makefiles" -DCMAKE_SH="CMAKE_SH-NOTFOUND" -B bin . cmake --build . cmake --build . --target install # optional
Do not use
Run As Administrator for
cmake in general.
Note that on Windows, CMake defaults
make to Visual Studio and Nmake.
cmake options above direct the build to MinGW.
sh.exe error with cmake
I get a nuisance error from
sh.exe being on the Path:
sh.exe was found in your PATH, here: C:/Program Files/Git/user/bin/sh.exe For MinGW make to work correctly sh.exe must NOT be in your path. Run cmake from a shill that does not have sh.exe in your PATH. If you want to use a UNIX shell, then use MSYS Makefile
this message by adding
-DCMAKE_SH="CMAKE_SH-NOTFOUND" to the
cmake command, like:
cmake -G "MinGW Makefiles" -DCMAKE_SH="CMAKE_SH-NOTFOUND" ..