问题描述
The CXX compiler identification is unknown
-- The C compiler identification is GNU 5.4.0
-- Check for working CXX compiler: /usr/local/bin/c++
-- Check for working CXX compiler: /usr/local/bin/c++ -- broken
CMake Error at /usr/share/cmake-3.5/Modules/CMakeTestCXXCompiler.cmake:54 (message):
The C++ compiler "/usr/local/bin/c++" is not able to compile a simple test
program.
It fails with the following output:
Change Dir: /home/ning/softwareo/opencv/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_77ead/fast"
/usr/bin/make -f CMakeFiles/cmTC_77ead.dir/build.make
CMakeFiles/cmTC_77ead.dir/build
make[1]: Entering directory
'/home/ning/softwareo/opencv/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_77ead.dir/testCXXCompiler.cxx.o
/usr/local/bin/c++ -o CMakeFiles/cmTC_77ead.dir/testCXXCompiler.cxx.o -c
/home/ning/softwareo/opencv/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
c++: error trying to exec 'cc1plus': execvp: Not a directory
CMakeFiles/cmTC_77ead.dir/build.make:65: recipe for target
'CMakeFiles/cmTC_77ead.dir/testCXXCompiler.cxx.o' failed
make[1]: *** [CMakeFiles/cmTC_77ead.dir/testCXXCompiler.cxx.o] Error 1
make[1]: Leaving directory
'/home/ning/softwareo/opencv/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_77ead/fast' failed
make: *** [cmTC_77ead/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:128 (project)
-- Configuring incomplete, errors occurred!
在编译时指定c++位置,即可解决,cmake时,加上下面的即可
cmake -DCMAKE_CXX_COMPILER=/usr/bin/c++ -DCMAKE_C_COMPILER=/usr/bin/c++ .
或者改为
cmake -DCMAKE_CXX_COMPILER=$(which g++) -DCMAKE_C_COMPILER=$(which gcc) .