Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"CMAKE_CXX_COMPILER broken" while compiling with CMake

Tags:

gcc

cmake

I'm trying to compile a Git project, and I'm facing some problems with CMake. Initially, it didn't find the C++ compiler and prompted an error:

cmake ..

No CMAKE_CXX_COMPILER could be found.

Tell CMake where to find the compiler by setting either the environment variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH.

So, I did:

CXX="gcc" cmake ..

But another error was prompted:

-- The CXX compiler identification is unknown
-- Check for working CXX compiler: /usr/bin/gcc
-- Check for working CXX compiler: /usr/bin/gcc -- broken
CMake Error at /usr/share/cmake-3.0/Modules/CMakeTestCXXCompiler.cmake:54 (message):
The C++ compiler "/usr/bin/gcc" is not able to compile a simple test program.

How can I solve this error and compile the project?

like image 928
ptkato Avatar asked Jul 15 '15 04:07

ptkato


Video Answer


2 Answers

You should try installing build-essential if you haven't done so.

Try this

sudo apt-get update
sudo apt-get install -y build-essential
like image 179
thiagoh Avatar answered Sep 28 '22 08:09

thiagoh


You are trying to use C compiler gcc as C++ one, which is wrong.

You need to install g++ or other C++ compiler.

like image 25
Tsyvarev Avatar answered Sep 28 '22 06:09

Tsyvarev