Gscienty / gsci-vimrc

1 stars 0 forks source link

centos 7.x 安装ycm的血与泪 #1

Open Gscienty opened 5 years ago

Gscienty commented 5 years ago

首先需要vim 8.1,编译时需要附加支持pythoninterp,下载vim8.1源码使用git,于是率先安装git,make,gcc.python,python-devel,ncurses-devel等内容。

yum install -y git make gcc python python-devel necurses-devel
git clone https://github.com/vim/vim.git
cd vim
./configure --with-features=huge \
        --enable-multibyte \
        --enable-pythoninterp=yes \
        --with-python-config-dir=/usr/lib/python3.7/config-3.7m-x86_64-linux-gnu \
        --enable-cscope
make
make install
Gscienty commented 5 years ago

由于ycm依赖llvm-clang,而编译llvm-clang是需要gcc5以上的版本,于是使用gcc7

wget https://mirrors.ustc.edu.cn/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz
tar zxvf gcc-7.3.0.tar.gz
cd gcc-7.3.0
yum -y group install "Development Tools"
./contrib/download_prerequisites
./configure --enable-checking=release --enable-languages=c,c++ --disable-multilib 
make -j4
make install
Gscienty commented 5 years ago

下次用docker得了。。。费这劲

Gscienty commented 5 years ago

编译llvm时,需要使用cmake3以上版本,需要进行安装, 并且编译完 gcc 之后,原来用yum安装的gcc需要删除

yum install -y cmake3
yum remove -y gcc
mkdir llvm-8.0.0.src/build
cd llvm-8.0.0.src/build
cmake .. -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/opt/llvm8  -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86"
make -j4
make install
Gscienty commented 5 years ago

编译llvm的过程中出现异常

../../bin/llvm-tblgen: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by ../../bin/llvm-tblgen)
../../bin/llvm-tblgen: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ../../bin/llvm-tblgen)
make[2]: *** [lib/IR/AttributesCompatFunc.inc] Error 1
make[1]: *** [lib/IR/CMakeFiles/AttributeCompatFuncTableGen.dir/all] Error 2
make: *** [all] Error 2

解决方案可以是升级libstdc++.so.6

yum provides libstdc++.so.6
yum install libstdc++

cp /usr/local/lib64/libstdc++.so.6.0.24 /usr/lib64/
rm /usr/lib64/libstdc++.so.6
ln -s /usr/local/lib64/libstdc++.so.6.0.24 /usr/lib64/libstdc++.so.6
Gscienty commented 5 years ago

然后就是clang的编译与安装(无坑)