根据官网的步骤安装(bcc/INSTALL.md at master · iovisor/bcc (github.com)),前提是需要系统升级,gcc版本最低要5.1,所以先升级gcc。
升级gcc的步骤可以参考这篇文章(Linux下GCC编译器的安装「建议收藏」-腾讯云开发者社区-腾讯云 (tencent.com)),但是还是会遇到一些问题,下面列出了安装过程遇到的问题。
在安装mpc时,会报找不到mpc,mpfr,gmp的so文件,所以根据文章的步骤,安装到mpc时需要先加上环境变量。
#编辑,添加以下内容,否则会报错找不到so文件
vim ~/.bashrc
export LD_LIBRARY_PATH=/usr/local/mpc-0.8.1/lib/:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/mpfr-2.4.2/lib/:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/gmp-4.3.2/lib/:$LD_LIBRARY_PATH
#也可以写到一起
然后就是安装gcc时,需要指定我们按照的mpc,mpfr,gmp,安装过程比较慢
/opt/gcc-5.3.0/configure --prefix=/usr/local/gcc-5.3.0 -enable-threads=posix -disable-checking -disable-multilib -enable-languages=c,c++ --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-2.4.2 --with-mpc=/usr/local/mpc-0.8.1
make && make install
安装完了之后,由于原来的gcc版本还在/usr/bin/目录下,所以我们需要创建链接
mv /usr/bin/gcc /usr/bin/gcc.bak
ln -s /usr/local/gcc-5.3.0/bin/gcc /usr/bin/gcc
mv /usr/bin/g++ /usr/bin/g++.bak
ln -s /usr/local/gcc-5.3.0/bin/g++ /usr/bin/g++
mv /usr/bin/c++ /usr/bin/c++.bak
ln -s /usr/local/gcc-5.3.0/bin/c++ /usr/bin/c++
mv /usr/bin/cpp /usr/bin/cpp.bak
ln -s /usr/local/gcc-5.3.0/bin/cpp /usr/bin/cpp
mv /usr/bin/gcov /usr/bin/gcov.bak
ln -s /usr/local/gcc-5.3.0/bin/gcov /usr/bin/gcov
mv /usr/bin/gcc-ar /usr/bin/gcc-ar.bak
ln -s /usr/local/gcc-5.3.0/bin/gcc-ar /usr/bin/gcc-ar
mv /usr/bin/gcc-nm /usr/bin/gcc-nm.bak
ln -s /usr/local/gcc-5.3.0/bin/gcc-nm /usr/bin/gcc-nm
mv /usr/bin/gcc-ranlib /usr/bin/gcc-ranlib.bak
ln -s /usr/local/gcc-5.3.0/bin/gcc-ranlib /usr/bin/gcc-ranlib
之后就是安装bcc了,根据官网给的步骤,先安装依赖包
yum install -y epel-release
yum install -y elfutils-libelf-devel cmake3 git bison flex ncurses-devel
yum install -y luajit luajit-devel # for Lua support
安装llvm,这里需要指定我们按照gcc的路径(第一次报错了,不知道为什么)
cmake3 -G "Unix Makefiles" -DLLVM_TARGETS_TO_BUILD="BPF;X86" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=/usr/bin/c++ -DCMAKE_C_COMPILER=/usr/bin/gcc ../llvm-10.0.1.src
make 到10%的时候会报错
../../../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 `CXXABI_1.3.9' 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)
需要将原来的libstdc++.so.6替换一下
cp /usr/local/gcc-5.3.0/lib64/libstdc++.so.6.0.21 /usr/lib64
ln -sf /usr/lib64/libstdc++.so.6.0.21 /usr/lib64/libstdc++.so.6
然后就是make && make install,过程也很漫长
最后安装bcc
mkdir
bcc
/build
;
cd
bcc
/build
cmake3 ..
make
sudo
make
install
标签:bin,gcc,..,local,c++,BCC,usr,安装,CentOS7.6
From: https://www.cnblogs.com/shen-ren-qiang/p/18347725