环境:ubuntu14.04
问题:编译YouCompleteMe时出现如下错误:
ubuntu:~/.vim/bundle/YouCompleteMe$ ./install.py --clang-completer
Searching Python 2.7 libraries...
Found Python library: /usr/lib/python2.7/config-x86_64-linux-gnu/libpython2.7.so
Found Python headers folder: /usr/include/python2.7
-- The C compiler identification is unknown
-- The CXX compiler identification is GNU 4.8.5
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- broken
CMake Error at /usr/share/cmake-3.5/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "/usr/bin/cc" is not able to compile a simple test program.
Searching Python 2.7 libraries...
Found Python library: /usr/lib/python2.7/config-x86_64-linux-gnu/libpython2.7.so
Found Python headers folder: /usr/include/python2.7
-- The C compiler identification is unknown
-- The CXX compiler identification is GNU 4.8.5
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- broken
CMake Error at /usr/share/cmake-3.5/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "/usr/bin/cc" is not able to compile a simple test program.
It fails with the following output:
Change Dir: /tmp/ycm_build_aZuJ5b/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_65fdf/fast"
/usr/bin/make -f CMakeFiles/cmTC_65fdf.dir/build.make
CMakeFiles/cmTC_65fdf.dir/build
CMakeFiles/cmTC_65fdf.dir/build
make[1]: Entering directory `/tmp/ycm_build_aZuJ5b/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_65fdf.dir/testCCompiler.c.o
/usr/bin/cc -o CMakeFiles/cmTC_65fdf.dir/testCCompiler.c.o -c
/tmp/ycm_build_aZuJ5b/CMakeFiles/CMakeTmp/testCCompiler.c
/tmp/ycm_build_aZuJ5b/CMakeFiles/CMakeTmp/testCCompiler.c
/tmp/ycm_build_aZuJ5b/CMakeFiles/CMakeTmp/testCCompiler.c:2:3: error:
#error "The CMAKE_C_COMPILER is set to a C++ compiler"
#error "The CMAKE_C_COMPILER is set to a C++ compiler"
# error "The CMAKE_C_COMPILER is set to a C++ compiler"
^
^
make[1]: *** [CMakeFiles/cmTC_65fdf.dir/testCCompiler.c.o] Error 1
make[1]: Leaving directory `/tmp/ycm_build_aZuJ5b/CMakeFiles/CMakeTmp'
make: *** [cmTC_65fdf/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:26 (project)
Call Stack (most recent call first):
CMakeLists.txt:26 (project)
-- Configuring incomplete, errors occurred!
See also "/tmp/ycm_build_aZuJ5b/CMakeFiles/CMakeOutput.log".
See also "/tmp/ycm_build_aZuJ5b/CMakeFiles/CMakeError.log".
ERROR: the build failed.
NOTE: it is *highly* unlikely that this is a bug but rather
that this is a problem with the configuration of your system
or a missing dependency. Please carefully read CONTRIBUTING.md
and if you're sure that it is a bug, please raise an issue on the
issue tracker, including the entire output of this script
and the invocation line used to run it.
that this is a problem with the configuration of your system
or a missing dependency. Please carefully read CONTRIBUTING.md
and if you're sure that it is a bug, please raise an issue on the
issue tracker, including the entire output of this script
and the invocation line used to run it.
解决方法:
将gcc g++编译器版本由 4.4.7 升级为5.0.4
关键步骤(以下步骤是必须的):sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-5 # gcc可以不升级依然用4.6,只装g++5
sudo apt-get install g++-5
sudo apt-get install gcc-5-multilib # gcc可以不升级依然用4.6,只装g++5
sudo apt-get install g++-5-multilib
sudo apt-get install g++-5-doc # 可选
可选(之后g++命令默认指向g++5.x.x)
sudo update-alternatives --config g++
根据提示选择默认的版本
现在就可以使用了,通过g++ -v 命令可以查看当前gcc或者g++的版本