====-----编译安装clang 3.6.0 编译器版本低---------------==============
[chunli@CentOS llvm-3.6.0]$ tar xf cfe-3.6.0.src.tar.xz
[chunli@CentOS llvm-3.6.0]$ tar xf clang-tools-extra-3.6.0.src.tar.xz
[chunli@CentOS llvm-3.6.0]$ tar xf compiler-rt-3.6.0.src.tar.xz
[chunli@CentOS llvm-3.6.0]$ tar xf llvm-3.6.0.src.tar.xz
[chunli@CentOS llvm-3.6.0]$ mv cfe-3.6.0.src llvm-3.6.0.src/tools/clang
[chunli@CentOS llvm-3.6.0]$ mv clang-tools-extra-3.6.0.src llvm-3.6.0.src/tools/clang/tools/extra
[chunli@CentOS llvm-3.6.0]$ mv compiler-rt-3.6.0.src llvm-3.6.0.src/projects/compiler-rt
[chunli@CentOS llvm-3.6.0]$ cd llvm-3.6.0.src
[chunli@CentOS llvm-3.6.0.src]$ ./configure --enable-optimized --enable-targets=host-only
[chunli@CentOS llvm-3.6.0.src]$ echo $?
[chunli@CentOS llvm-3.6.0.src]$ make
cc1plus: error: unrecognized command line option "-std=c++11"
cc1plus: warning: unrecognized command line option "-Wno-maybe-uninitialized"
解决办法,安装gcc 4.8
编译安装clang 3.6.2 编译器自身BUG
=====--------------编译安装clang 3.6.2 编译器自身BUG---------------------=============
需要C++11标准支持
需要Python2.7 支持
[chunli@CentOS llvm3.6.2]$ tar xf cfe-3.6.2.src.tar.xz
[chunli@CentOS llvm3.6.2]$ tar xf clang-tools-extra-3.6.2.src.tar.xz
[chunli@CentOS llvm3.6.2]$ tar xf compiler-rt-3.6.2.src.tar.xz
[chunli@CentOS llvm3.6.2]$ tar xf llvm-3.6.2.src.tar.xz
[chunli@CentOS llvm3.6.2]$ mv cfe-3.6.2.src llvm-3.6.2.src/tools/clang
[chunli@CentOS llvm3.6.2]$ mv compiler-rt-3.6.2.src llvm-3.6.2.src/projects/compiler-rt
[chunli@CentOS llvm3.6.2]$ mv clang-tools-extra-3.6.2.src llvm-3.6.2.src/tools/clang/extra
[chunli@CentOS llvm3.6.2]$ mkdir build
[chunli@CentOS llvm3.6.2]$ cd build
[chunli@CentOS build]$ ../llvm-3.6.2.src/configure --enable-optimized --enable-targets=host-only
[chunli@CentOS build]$ echo $?
[chunli@CentOS build]$ make
llvm[4]: Linking Release+Asserts executable clang-check (without symbols)
/tmp/tools/llvm3.6.2/build/tools/clang/tools/clang-check/Release+Asserts/ClangCheck.o: In function `std::unique_ptr<clang::tooling::FrontendActionFactory, std::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<(anonymous namespace)::ClangCheckActionFactory>((anonymous namespace)::ClangCheckActionFactory*, clang::tooling::SourceFileCallbacks*)::FrontendActionFactoryAdapter::create()':
ClangCheck.cpp:(.text._ZZN5clang7tooling24newFrontendActionFactoryIN12_GLOBAL__N_123ClangCheckActionFactoryEEESt10unique_ptrINS0_21FrontendActionFactoryESt14default_deleteIS5_EEPT_PNS0_19SourceFileCallbacksEEN28FrontendActionFactoryAdapter6createEv+0x40): undefined reference to `vtable for std::unique_ptr<clang::tooling::FrontendActionFactory, std::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<(anonymous namespace)::ClangCheckActionFactory>((anonymous namespace)::ClangCheckActionFactory*, clang::tooling::SourceFileCallbacks*)::FrontendActionFactoryAdapter::ConsumerFactoryAdaptor'
collect2: error: ld returned 1 exit status `
看起来像是gcc的bug
编译安装clang 3.8.1
=====--------------编译安装clang 3.8.1---------------------=============
[chunli@CentOS llvm3.8.1]$ tar xf cfe-3.8.1.src.tar.xz
[chunli@CentOS llvm3.8.1]$ tar xf clang-tools-extra-3.8.1.src.tar.xz
[chunli@CentOS llvm3.8.1]$ tar xf compiler-rt-3.8.1.src.tar.xz
[chunli@CentOS llvm3.8.1]$ tar xf llvm-3.8.1.src.tar.xz
[chunli@CentOS llvm3.8.1]$ mv cfe-3.8.1.src llvm-3.8.1.src/tools/clang
[chunli@CentOS llvm3.8.1]$ mv compiler-rt-3.8.1.src llvm-3.8.1.src/projects/compiler-rt
[chunli@CentOS llvm3.8.1]$ mv clang-tools-extra-3.8.1.src llvm-3.8.1.src/tools/clang/extra #!
[chunli@CentOS llvm3.8.1]$ mkdir build && cd build/
[chunli@CentOS build]$ ../llvm-3.8.1.src/configure --enable-optimized --enable-targets=host-only
checking for python >= 2.7... not found
configure: error: found python 2.6.6 (/usr/bin/python); required >= 2.7
解决办法 去安装编译安装Python2.7
编译安装clang 3.8.1
=====--------------编译安装clang 3.8.1---------------------=============
[chunli@CentOS llvm3.8.1]$ tar xf cfe-3.8.1.src.tar.xz
[chunli@CentOS llvm3.8.1]$ tar xf clang-tools-extra-3.8.1.src.tar.xz
[chunli@CentOS llvm3.8.1]$ tar xf compiler-rt-3.8.1.src.tar.xz
[chunli@CentOS llvm3.8.1]$ tar xf llvm-3.8.1.src.tar.xz
[chunli@CentOS llvm3.8.1]$ mv cfe-3.8.1.src llvm-3.8.1.src/tools/clang
[chunli@CentOS llvm3.8.1]$ mv compiler-rt-3.8.1.src llvm-3.8.1.src/projects/compiler-rt
[chunli@CentOS llvm3.8.1]$ mv clang-tools-extra-3.8.1.src llvm-3.8.1.src/tools/clang/extra #!
[chunli@CentOS llvm3.8.1]$ mkdir build && cd build/
[chunli@CentOS build]$ ../llvm-3.8.1.src/configure --enable-optimized --enable-targets=host-only
[chunli@CentOS build]$ echo $?
[chunli@CentOS build]$ make
llvm[4]: Linking Release+Asserts executable clang-check (without symbols)
/home/chunli/tools/llvm3.8.1/build/tools/clang/tools/clang-check/Release+Asserts/ClangCheck.o: In function `std::unique_ptr<clang::tooling::FrontendActionFactory, std::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<(anonymous namespace)::ClangCheckActionFactory>((anonymous namespace)::ClangCheckActionFactory*, clang::tooling::SourceFileCallbacks*)::FrontendActionFactoryAdapter::create()':
ClangCheck.cpp:(.text._ZZN5clang7tooling24newFrontendActionFactoryIN12_GLOBAL__N_123ClangCheckActionFactoryEEESt10unique_ptrINS0_21FrontendActionFactoryESt14default_deleteIS5_EEPT_PNS0_19SourceFileCallbacksEEN28FrontendActionFactoryAdapter6createEv+0x40): undefined reference to `vtable for std::unique_ptr<clang::tooling::FrontendActionFactory, std::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<(anonymous namespace)::ClangCheckActionFactory>((anonymous namespace)::ClangCheckActionFactory*, clang::tooling::SourceFileCallbacks*)::FrontendActionFactoryAdapter::ConsumerFactoryAdaptor'
collect2: error: ld returned 1 exit status`
编译器缺陷? ld连接报错 , 更换为gcc 4.8.5解决
编译安装clang 3.8.1
=====--------------编译安装clang 3.8.1---------------------=============
[chunli@CentOS llvm3.8.1]$ tar xf cfe-3.8.1.src.tar.xz
[chunli@CentOS llvm3.8.1]$ tar xf clang-tools-extra-3.8.1.src.tar.xz
[chunli@CentOS llvm3.8.1]$ tar xf compiler-rt-3.8.1.src.tar.xz
[chunli@CentOS llvm3.8.1]$ tar xf llvm-3.8.1.src.tar.xz
[chunli@CentOS llvm3.8.1]$ mv cfe-3.8.1.src llvm-3.8.1.src/tools/clang
[chunli@CentOS llvm3.8.1]$ mv compiler-rt-3.8.1.src llvm-3.8.1.src/projects/compiler-rt
[chunli@CentOS llvm3.8.1]$ mv clang-tools-extra-3.8.1.src llvm-3.8.1.src/tools/clang/extra #!
[chunli@CentOS llvm3.8.1]$ mkdir build && cd build/
[chunli@CentOS build]$ ../llvm-3.8.1.src/configure --enable-optimized --enable-targets=host-only
[chunli@CentOS build]$ echo $?
[chunli@CentOS build]$ make
llvm[4]: Copying runtime library linux/builtins-i386 to build dir
llvm[4]: Copying runtime library linux/profile-i386 to build dir
cp: cannot stat `/home/chunli/tools/llvm3.8.1/build/tools/clang/runtime/compiler-rt/clang_linux/builtins-i386/libcompiler_rt.a': No such file or directory
cp: cannot stat `/home/chunli/tools/llvm3.8.1/build/tools/clang/runtime/compiler-rt/clang_linux/profile-i386/libcompiler_rt.a': No such file or directory`
这种问题不知道怎么搞.....放弃这个clang版本
编译安装clang 3.9.1
=====--------------编译安装clang 3.9.1---------------------=============
需要C++11标准支持
需要Python2.7 支持
[chunli@CentOS ~]$ cd tools/
[chunli@CentOS tools]$ tar xf cfe-3.9.1.src.tar.xz
[chunli@CentOS tools]$ tar xf compiler-rt-3.9.1.src.tar.xz
[chunli@CentOS tools]$ tar xf llvm-3.9.1.src.tar.xz
[chunli@CentOS tools]$ mv cfe-3.9.1.src llvm-3.9.1.src/tools/clang
[chunli@CentOS tools]$ mv compiler-rt-3.9.1.src llvm-3.9.1.src/projects/compiler-rt
[chunli@CentOS tools]$ mkdir llvm_build
[chunli@CentOS tools]$ cd llvm_build
[chunli@CentOS llvm_build]$ cmake -G "Unix Makefiles" ../llvm-3.9.1.src
CMake Error at cmake/modules/CheckCompilerVersion.cmake:12 (message):
Host GCC version must be at least 4.7!
Call Stack (most recent call first):
cmake/config-ix.cmake:14 (include)
CMakeLists.txt:461 (include)
.......................................................
系统自带的编译器没有卸载, 卸载系统自带的编译器,
再次执行cmake 他会提示找不到/usr/bin/cc,/usr/bin/c++
如下:
编译YouCompleteMe 找不到编译器
=====--------------编译YouCompleteMe 找不到编译器-------------=============
[chunli@CentOS ~]$ cd ~
[chunli@CentOS ~]$ mkdir ycm_build/ && cd ycm_build/
[chunli@CentOS ycm_build]$ sudo yum remove gcc #删除自带的低版本gcc
[chunli@CentOS ycm_build]$ sudo yum remove g++ #删除自带的低版本g++
[chunli@CentOS ycm_build]$ cmake -G "Unix Makefiles" -DEXTERNAL_LIBCLANG_PATH=/usr/local/lib/libclang.so.3.9 . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:26 (project):
The CMAKE_C_COMPILER:
/usr/bin/cc
is not a full path to an existing compiler tool.
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
CMake Error at CMakeLists.txt:26 (project):
The CMAKE_CXX_COMPILER:
/usr/bin/c++
is not a full path to an existing compiler tool.
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.
-- Configuring incomplete, errors occurred!
See also "/home/chunli/ycm_build/CMakeFiles/CMakeOutput.log".
See also "/home/chunli/ycm_build/CMakeFiles/CMakeError.log".
[chunli@CentOS ycm_build]$
解决办法
/usr/local/bin/gcc
[chunli@CentOS ycm_build]$ sudo ln -s /usr/local/bin/gcc /usr/bin/cc
[chunli@CentOS ycm_build]$ sudo ln -s /usr/local/bin/g++ /usr/bin/c++
编译安装clang 3.9.1, 内存耗尽
=====--------------编译安装clang 3.9.1, 内存耗尽---------------------=============
需要C++11标准支持
需要Python2.7 支持
[chunli@CentOS ~]$ cd tools/
[chunli@CentOS tools]$ tar xf cfe-3.9.1.src.tar.xz
[chunli@CentOS tools]$ tar xf compiler-rt-3.9.1.src.tar.xz
[chunli@CentOS tools]$ tar xf llvm-3.9.1.src.tar.xz
[chunli@CentOS tools]$ mv cfe-3.9.1.src llvm-3.9.1.src/tools/clang
[chunli@CentOS tools]$ mv compiler-rt-3.9.1.src llvm-3.9.1.src/projects/compiler-rt
[chunli@CentOS tools]$ mkdir llvm_build
[chunli@CentOS tools]$ cd llvm_build
[chunli@CentOS llvm_build]$ cmake -G "Unix Makefiles" ../llvm-3.9.1.src
[chunli@CentOS llvm_build]$ make
../../../../lib/libclangStaticAnalyzerCheckers.a: could not read symbols: Memory exhausted
collect2: error: ld returned 1 exit status
make[2]: *** [bin/clang-3.9] Error 1
make[1]: *** [tools/clang/tools/driver/CMakeFiles/clang.dir/all] Error 2
make: *** [all] Error 2
解决
[chunli@CentOS llvm_build]$ cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86" ../llvm-3.9.1.src
[chunli@CentOS llvm_build]$ make -j 4
启动vim报错
启动vim报错
The ycmd server SHUT DOWN (restart with ':YcmRestartServer').... code -11.
Use the ':YcmToggleLogs' command to check the logs.
:YcmDebugInfo 查看错误
Printing YouCompleteMe debug information...
-- Client logfile: /tmp/ycm_RtQuPY.log
-- Server errored, no debug info from server
-- Server running at: http://127.0.0.1:52237
-- Server process ID: 2947
-- Server logfiles:
-- /tmp/ycmd_52237_stdout_lrHj02.log
-- /tmp/ycmd_52237_stderr_80SRfh.log
Press ENTER or type command to continue
[chunli@CentOS ~]$ vim /tmp/ycm_RtQuPY.log
2017-03-09 18:02:22,569 - ERROR - Unable to connect to server
:YcmDiags
Native filetype completion not supported for current file, cannot force recompilation.
:messages
Messages maintainer: Bram Moolenaar <Bram@vim.org>
"main.c" 5L, 35C
The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). Unexpected exit code 1. Use the ':YcmToggleLogs' command to check
the logs.
:YcmRestartServer
Restarting ycmd server...