安装依赖包
wget https://copr.fedorainfracloud.org/coprs/ngompa/musl-libc/repo/epel-7/ngompa-musl-libc-epel-7.repo -O /etc/yum.repos.d/ngompa-musl-libc-epel-7.repo --no-check-certificate
yum install -y musl-libc-static
安装gcc-9.5
yum install -y m4 gcc-c++
cd /usr/local/src
# 下载gcc9.5.0源码
wget http://ftp.gnu.org/gnu/gcc/gcc-9.5.0/gcc-9.5.0.tar.gz
tar -zxvf gcc-9.5.0.tar.gz
# 进入gcc目录安装
cd gcc-9.5.0
# 下载某些依赖包
./contrib/download_prerequisites
# 创建bulid文件夹
mkdir build
cd build
../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
# 编译安装,此过程耗时较长
make && make install
mv /usr/bin/gcc /usr/bin/gcc_bak
ln -s /usr/local/gcc/bin/gcc /usr/bin/gcc
mv /usr/bin/g++ /usr/bin/g++_bak
ln -s /usr/local/gcc/bin/g++ /usr/bin/g++
cp ./stage1-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.28 /lib64
rm /lib64/libstdc++.so.6
ln -s /lib64/libstdc++.so.6.0.21 /lib64/libstdc++.so.6
安装boost 1.65.1
下载安装包https://boostorg.jfrog.io/artifactory/main/release/1.65.1/source/boost_1_65_1.zip
解压后执行:
./bootstrap.sh
./b2 install --prefix=/usr/local/lib/boost
在/etc/profile文件中添加
export CPLUS_INCLUDE_PATH=/usr/local/lib/boost/include:$CPLUS_INCLUDE_PATH
export LIBRARY_PATH=/usr/local/lib/boost/lib:$LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/lib/boost/lib:$LD_LIBRARY_PATH
之后,执行source /etc/profile
安装c++插件protobuf-cpp
wget https://github.com/protocolbuffers/protobuf/releases/download/v21.5/protobuf-cpp-3.21.5.zipunzip protobuf-cpp-3.21.5.zip
cd protobuf-3.21.5
./configure
make -j20
make install
安装python插件protobuf-python
需要提前安装好python3.8
wget https://github.com/protocolbuffers/protobuf/releases/tag/v21.5/protobuf-python-4.21.5.zip
unzip protobuf-python-4.21.5.zip
cd protobuf-4.21.5
cd python
python3 setup.py build
python3 setup.py install
拷贝依赖库文件
cp ./src/.libs/libprotobuf.so.32.0.5 /lib64
ln -s /lib64/libprotobuf.so.32.0.5 /lib64/libprotobuf.so.32
常见问题:
问题:PCL在linux下运行PCLVisualizer报错: undefined reference to symbol ‘pthread_condattr_setclock@@GLIBC_2.3.3‘
解决:https://zhuanlan.zhihu.com/p/132481781
问题:Could NOT find Boost (missing: Boost_INCLUDE_DIR)
解决:修改CMakelist加入:
set(BOOST_ROOT /usr/local/lib/boost/include)
set(Boost_LIBRARY_DIRS /usr/local/lib/boost/lib)
问题:undefined reference to `std::__cxx11::collate<wchar_t> const& std::use_facet<std::__cxx11::collate<w
解决:修改CMakelist加入:set(CMAKE_CXX_COMPILER "/bin/g++")