I am trying to use cmake to build the Box2D library for c++. When I run cmake gui I get the error:
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
Configuring incomplete, errors occurred!
Most questions like these people have answered by saying "Add MinGw/bin to the PATH" but I already have that on the PATH. What else could be causing this error?
mingw32-make.exe can be installed with the standard MinGW32 installer via the appropriate checkbox:
As rubenvb points out, you'll still need to ensure that it makes it into your PATH. If you edit your environment variables via System Properties, be sure to close and reopen the CMake GUI.
If you're more accustomed to using make.exe, install MSYS and use MSYS Makefiles as the CMake generator. You'll also need to put both mingw\bin and msys\1.0\bin into your PATH.
I had the same problem and I added these three to my system path and errors were solved.
C:\Program Files\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64\bin
C:\Program Files\CMake\bin
C:\opencv\build\install\x64\mingw\bin
You can check this answer: https://stackoverflow.com/a/74240235/3110429
Firstly check the system.
Install MINGW https://www.msys2.org/
Install gcc, g++, gdb, and cmake using pacman.
pacman -S mingw-w64-x86_64-gcc
pacman -S mingw-w64-x86_64-gdb
pacman -S mingw-w64-x86_64-cmake
Check installation:
gcc --version
g++ --version
gdb --version
Edit environment variables for your account (PATH)
C:\msys64\mingw64\bin
For cmake project on Vscode:
Create a cmake project: https://code.visualstudio.com/docs/cpp/cmake-linux#_create-a-cmake-project
Choose the Kit (Toolchain) which was installed before
Set cmake.cmakePath (If you installed with pacman, the path should be same as gcc/g++.
"cmake.cmakePath": "C:\msys64\mingw64\bin\cmake.exe"
Reset VScode: Ctrl+shift+P and type "CMake:Reset CMake Tools for Extension State"
Configure project: Ctrl+shift+P and type "CMake: Configure". You will see "built" directory and generated files.
In the path MinGW\bin try to find make.exe or mingw32-make.exe. If you don't have it then mingw32-make.exe can be installed with the standard MinGW32 installer as shown in the pervious answer.
Then have a second copy of make.exe or mingw32-make.exe to have identical two files with those names make.exe and mingw32-make.exe
and it solved my problem.
I'm trying to follow this tutorial to get started with OpenGL: http://www.learnopengl.com/#!Getting-started/Creating-a-window and it requires downloading glfw and CMake.
I have set the downloaded glfw folder as the source code folder and I have created inside that folder another one called "build" which I then set as the build one for the binaries, as the tutorial asks.
I click on "Configure" and I select XCode as the Generator, since I'm on a Mac.
The problem is that when I try to configure the project CMake gives me this error:
The C compiler identification is unknown
CMake Error at CMakeLists.txt:3 (project):
No CMAKE_C_COMPILER could be found.
Configuring incomplete, errors occurred!
See also "/Users/standard/Desktop/glfw-3.2.1/build/CMakeFiles/CMakeOutput.log".
See also "/Users/standard/Desktop/glfw-3.2.1/build/CMakeFiles/CMakeError.log".
I've already read this question, but as far as I can understand, it doesn't have what I need:
CMake error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found
If you have installed Xcode or Command Line Tools for Xcode, try this:
sudo xcode-select --reset
This happened to me with Xcode10 / Cmake 3.12 after installing Homebrew. Running sudo xcode-select --reset fixed it for me.
Did you install Xcode and Xcode Commandline Tools?
xcode-select --install
If you have Xcode Commandline Tools installed, you should no longer be receiving the xcrun is missing error.
How did you install Cmake? Once you have ensured that Xcode Commandline Tools is installed, please completely remove Cmake from your system and reinstall it. You have a screwed up configuration. There are ways to debug and fix it without a clean install, but since you are new to this, it will be the easiest and lest frustrating way.
Failing that if you do have Xcode Commandline Tools installed, hstdt suggested trying this:
sudo xcode-select --reset
This error means CMake cannot find your standard C/C++ Compiler, looks like you'll need to export the environment variables yourself. you can find the path of your C/C++ compiler with:
xcrun -find c++
xcrun -find cc
Then afterwards when you have the paths, create two variables inside the gui. If you are running it from the cline, it would be something like
cmake -D CMAKE_C_COMPILER="/path/to/your/c/compiler/executable" -D CMAKE_CXX_COMPILER="/path/to/your/cpp/compiler/executable" ...
On a fresh Xcode install the command line tools complain about agreeing to the EULA which build tools don't like. Which you can do with:
sudo xcodebuild -license
If you are on a Mac computer and have Homebrew, you can simply upgrade cmake, forcing the compiler to be reconfigured:
brew upgrade cmake
In my case, I needed to install CMake from CMake official site, download the .dmg, install it and then add the CMake folder the system's PATH.
Before the installation, the output of which cmake is /usr/local/bin/cmake.
After the installation it should be something like /Applications/CMake.app/Contents/bin/cmake.
This has solved the issue for me.
I get exactly this error if ccache is enabled on my machine. Disabling ccache fixed the problem for me.
To check if ccache is enabled, print the systems variables CC or CXX:
echo $CC
echo $CXX
This prints something like the following: ccache clang -Qunused-arguments -fcolor-diagnostics. (CC or CXX are typically overridden by the .bashrc or .zshrc file.)
To disable ccache, use the following:
CC=clang
CXX=clang++
Then rebuild the cmake project:
cmake -G Xcode <path/to/CMakeLists.txt>
Apparently, it is possible to use CMake's Xcode generator also in combination with ccache, as is described here. But I never tried it out myself.
I got this error when I had an invalid value set for CMAKE_OSX_SYSROOT. I was trying to give it the name of the SDK e.g. "macOS 10.13". Setting it to the full path of the SDK resolved the issue.
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk
Compiler detection appears to be broken with Xcode 10 and older versions of CMake. I know that it broke for me with CMake 2.2 and upgrading to the latest (2.13) solved it for me. It was working fine with Xcode 9 and it broke with the upgrade. I tried the other solutions (all good depending on your situation) but upgrading CMake fixed the issue.
If you are on CLion and facing this issue try changing the C and C++ compiler location inside Toolchains settings to the latest one. the default GCC installation directory is /usr/local/Cellar/gcc/...
after I upgrade Xcode to new verison, I met this error, then I upgrade my cmake version, problem solved.
For anyone coming to this question nowadays from google, my problem was fixed via
xcodebuild -runFirstLaunch
I found this by inspecting CMakeFiles/CMakeError.log
I have been building LLVM and clang 3.8 using svn for some time now. I started using git (this is not the cause of the problem) today and an error interrupted the build process that I have seen before. When make is trying to build the i386 sanitizer library it fails. I was able to disable building the sanitizers in ccmake by setting COMPILER_RT_BUILD_SANITIZERS to OFF. I would prefer to disable building the i386 target altogether. Does anyone know how to do this?
compiler-rt needs to be built out of tree. This is done so that it can be compiled with the newly built clang.
This process will only build the supported architecture, x86_64 in my case.
The following example uses the default install prefix (/usr/local)
to specify the location of llvm-config.
Once LLVM is built, change the directory to where you want compiler-rt
then:
svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mkdir build
cd build
cmake ../compiler-rt -DLLVM_CONFIG_PATH=/usr/local/bin/llvm-config
make
make install
I would like to create an install script for objectiveC with arc and dispatch_queue support for Raspberry Pi. This script will be open sourced in github. Right now lots of the progress is working. But while installing libobjc2 the compiler complains:
error: -fobjc-arc is not supported with fragile abi
I know that I have to set the -fobjc-nonfragile-abi flag to the clang compiler.
Unfortunately I don't know lot about cmake and how to pass arguments to cmake.
This is suggested by GNUstep and works until the error appears:
cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
How do I tell cmake using the command line to use the "-fobjc-nonfragile-abi" flag?
You can always append defines like that with SET:
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fobjc-nonfragile-abi")
But I haven't use clang, so It's only a guess one
I want to compile httpd into LLVM bytecode using clang. First I tried compiling it using gcc, for which I did the following:
./configure --prefix=/home/varun/apache/httpd/gcc --with-included-apr
make
sudo make install
And it successfully installs!
Now, I try compiling it with clang, for which I do the following:
CC="clang" CFLAGS="-O4" ./configure --prefix=/home/varun/apache/httpd/clang --with-included-apr
make # didn't come to this step
sudo make install # didn't come to this step
And, the configure itself fails. I chose -O4 as I read that LLVM outputs bytecode if you use -O4 or -emit-llvm as CFLAGS(neither of them work).
This is the error I get:
checking whether the C compiler works... no
configure: error: in `/home/varun/apache/httpd/httpd-2.4.3/srclib/apr':
configure: error: C compiler cannot create executables
Is this related to the the linker not being able to link the LLVM bytecode files?
[I knew it was something related to the linking step, but was not able to get things working. Finally compilation successful, so I'm writing my own answer]
Approach 1 (Failed)
Installed clang on my system using the Synaptic Package Manager.
Installed binutils-gold, because that is required to give the LLVMgold.so as a plugin to the linker. But for this the clang which was installed, should have the gold plugin.
Trying to configure httpd with this command:
CC="clang" CFLAGS="-O4" ./configure --prefix=/home/varun/work/httpd/build --with-included-apr
Here, --with-included-apr is required by httpd. -O4 is required so that the compilation happens through bytecode.
This configuration step itself fails, because the clang which is installed doesn't have the proper plugin for enabling the linker to link bytecode object files.
Approach 2 (Success)
Installed binutils-gold. Also obtained the source of binutils.
Compiling LLVM and using the binutils source code to compile, so that LLVM has the gold plugin.
Compile LLVM,
../configure --with-binutils-include=/usr/src/binutils/binutils-2.22/include --enable-gold --prefix=/usr/local
make
sudo make install
ln -s /usr/local/lib/LLVMgold.so /usr/lib/bdf-plugins/LLVMgold.so
Now, compile httpd
CC="clang" CFLAGS="-O4" ./configure --prefix=/home/varun/work/httpd/build --with-included-apr
make
sudo make install
LLVM bytecode is an intermediate representation used within LLVM. It cannot be executed by any machine. That's why the configure script is complaining that
C compiler cannot create executables.
Do not output LLVM bytecode. Try to use other optimization level instead. (and don't use -emit-llvm in CFLAGS as well).
I answered a very similar question here:
Generate LLVM IR for httpd
It is actually easy to build IR for most well written projects.
Shameless plug for our tool:
https://github.com/SRI-CSL/whole-program-llvm
Good luck.