自己在一台boost 1.41 的机器上编译使用 boost 1.39 的机器上编写调试的文件时,报错。
使用调用 boost 的语法报错。尝试把机器上的boost 修改为 boost 1.39, 通过boost 网站下载源码编译,安装,依旧报错。
后来在网上查到有人遇到类似的问题,他使用较高的boost版本后,问题就解决了。所以自己就安装 boost 1_65。 文件的编译问题解决。
1 安装方法一
1.1下载源码
1.2 配置环境, 生产编译工具
解压 文件 boost_1_65_1
进入 boost_1_65_1 目录
执行
sh bootstrap.sh
1.3编译
./b2
1.4 文件拷贝,完成安装
至此, boost_1_65_1 路径下已生成 boost 以及 stage 目录
cp -rf boost /usr/include
cp -rf stage/lib/* /usr/lib64
至此,文件可以正常编译
2 安装方法二
命令安装
2.1 自定义路径安装
在编译步骤后,也可以使用命令安装,即
./b2 install /self-custom-path
boost 预计lib 文件安装后的路径如下
self-custom-path/include/boost
self-custom-path/lib
这种自定义路径,系统不一定能找到。
2.2 系统配置
这是就用通过ldconfig 使动态链接库为系统所共享
在 /etc/ld.so.conf 中添加路径作为单独一行。 如:
/self-custom-path
或者在目录
/etc/ld.so.conf.d
下添加一个文件,名字自定义,如: boostlib.conf
然后在 /etc/ld.so.conf 中添加一行
include ld.so.conf.d/*.conf
然后执行
ldconfig
更多可以参看 ldconfig 命令的使用
http://man.linuxde.net/ldconfig
参考文章:
CentOS 7下编译安装Boost_1_57_0
https://www.cnblogs.com/xiehongfeng100/p/4375613.html