2015-07-15 20 views
5

Sto provando a compilare un progetto git e sto affrontando alcuni problemi con CMake. Inizialmente, non ha trovato il compilatore C++ e ha spinto un errore:Errori durante la compilazione con CMake

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.

Così, ho fatto:

CXX="gcc" cmake .. 

Ma un altro errore è stato chiesto:

-- 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.

Come posso risolvere questo errore e compilare il progetto?

+0

Stai cercando di utilizzare CMake su un sistema Linux o Mac OS? CMake dovrebbe essere in grado di rilevare automaticamente il compilatore predefinito sulla macchina. Cosa restituisce il comando 'g ++ -v' in un terminale? – Antwane

+0

Sistema Linux. A proposito di 'g ++ -v', lancia un" comando non trovato ". – Patrick

risposta

6

si tenta di utilizzare C compilatore gcc come C++ uno, che è sbagliato.

È necessario installare g++ o altro compilatore C++.

+0

Davvero? Ho letto [questa risposta] (http://stackoverflow.com/a/173007/3029543) e, a mio avviso, dice che il gcc può compilare sia i programmi C che C++. – Patrick

+2

Può, ma richiede almeno la libreria stdC++, che viene fornita con g ++. Basta installare g ++ e tutto funzionerà senza intervento come l'impostazione della variabile CXX. – Tsyvarev

+0

Grazie, ha funzionato alla perfezione. – Patrick

11

Si dovrebbe provare a installare build-essential se non lo si è fatto.

Prova questa

sudo apt-get update 
sudo apt-get install -y build-essential 
+0

Questo ha risolto il problema per me. Ma perché? Cosa fa il pacchetto 'build-essential'? –

+0

https://superuser.com/a/151558/170267 – iamchriswick

Problemi correlati