centos版本
安装依赖
yum -y install python3
yum -y install python36-devel
ln -s /usr/include/python3.6m/* /usr/include/
如果不执行软连接,boost在编译时会报很多的警告
安装boost
最近用到了webrtc,选择了kurento技术栈,官网提到了在Ubuntu编译部署和使用docker部署。但实际中服务器是centos,还不允许用docker部署😎,太无语了😂。最后想了想是否可以通过编译kurento源码部署,编译时需要用到cmake,这里记录下:
下载对应版本的boost
https://sourceforge.net/projects/boost/files/boost/1.78.0/
tar xvf boost_1_78_0.tar.gz
cd boost_1_78_0
./bootstrap.sh
./b2 install
如果采用./b2 install编译,会在引用的过程中报recompile with -fPIC,故建议采用如下方式编译
./b2 include=static,shared link=static link=shared cxxflags=-fPIC cflags=-fPIC install
编译安装完成后,会把boost头文件拷贝到/usr/local/include/目录下,库文件在/usr/local/lib/下。
使用boost出现的问题
1、cmake时,会出现如下的错误
CMake Error at /usr/local/lib/cmake/Boost-1.78.0/BoostConfig.cmake:240 (cmake_policy):
Policy "CMP0057" is not known to this version of CMake.
需要安装上面的提示找到改行命令
将上面的修改为如下内容
if(POLICY CMP0057)
cmake_policy(SET CMP0057 NEW) # if IN_LIST
endif()
2、报if given arguments:“all”“in_list”“boost_find_components” unknown arguments specified
测试出是boost和cmake版本不匹配
解决:cmake升级到3.22.2