安装完最新的Boost库

官方说明中有一句话:

Finally,

$ ./b2 install

will leave Boost binaries in the lib/ subdirectory of your installation prefix. You will also find a copy of the Boost headers in the include/ subdirectory of the installation prefix, so you can henceforth use that directory as an #include path in place of the Boost root directory.

大部分Boost库无需动态或静态编译链接,小部分如regex   thread   coroutine之类的库在编译自己的源代码时需要加入链接提示

比如在编译使用regex的库时命令如下:

c++ -I /usr/local/include/boost/ main.cpp -o test1 -L /usr/local/lib -lboost_regex

完成后运行时:

LD_LIBRARY_PATH="/usr/local/lib" ./test1

否则会报错:

error while loading shared libraries: libboost_regex.so.1.64.0: cannot open shared object file: No such file or directory

这个错误在stackoverflow上给的解释是:

The library cannot be found.

Libraries are by default looked for in /lib/usr/lib and the directories specified by /etc/ld.so.conf.

Usually system libraries (like boost, if you installed it via your package manager) are located in /usr/lib, but it's probably not your case.

Where are your boost libraries located on your system? Did you compile them by yourself? In this case you should tell the dynamic linker to look for your libraries in the directory they're located by using the LD_LIBRARY_PATH environment variable:

LD_LIBRARY_PATH="your/boost/directory" ./testfgci

I'd suggest you to install boost libraries using your package manager, anyway, this will make your life a lot simpler.

也就是说系统在运行程序时要先加载动态库,系统的搜寻目录在/etc/ld.so.conf或者/etc/ld.so.conf.d/*.conf中,而该目录中没有链接库所在的位置,要在该文件中手动加入目录地址或者在运行程序之前指定LD_LIBRARY_PATH的值

这样才能正确识别动态库

------------------------------------------------------------------------------------------------------------

更新:

一个更方便的方法是在IDE的environment variable中添加LD_LIBRARY_PATH=/usr/local/lib

然后运行即可,要不然只能使用terminal来运行

转载于:https://www.cnblogs.com/burningTheStar/p/6869581.html

解决Boost库链接出错问题相关推荐

  1. linux下boost库链接动态库失败

    echo "boost库lib安装路径" >>/etc/ld.so.conf 加入动态库的地方 执行动态库命令 sudo ldconfig

  2. 手把手教你:解决boost库编译使用后thread类使用报错的方法

    报错如下: libboost_thread-vc110-mt-1_53.lib(thread.obj) : error LNK2038.... error LNK2038: 检测到"_ITE ...

  3. Ubuntu下添加boost库

    @Ubuntu下Boost库的链接 在CmakeLists.txt中添加Boost组件 Boost具有很好的平台独立性,因此可以作为首选api来完成特定功能. 最常用的为filesystem,用来获取 ...

  4. 记boost在gcc的一个库链接问题generic_category()

    报错大致如下: main.cpp:(.text+0x49): undefined reference to `boost::system::generic_category()' main.cpp:( ...

  5. linux动态库路径生效,Linux下如何解决动态库的链接问题

    原标题:Linux下如何解决动态库的链接问题 静态库是一种以空间换取时间和移植性的做法,一些情况下确实有着一定的意义,但是一些情况下,我们自己编写的简单项目,在绝大多数的机器上不存在移植性问题,是没有 ...

  6. 动态库链接boost静态库

    为了避免项目布署麻烦,需要将执行文件尽量静态链接 1. boost库全部静态链接 2. c++库静态链接 1,2点的改变如下,强制链静态库的方法为参数下为-l:libXXXX.a; 对于boost l ...

  7. vs2017编译boost库 ,解决无法打开文件“libboost_filesystem-vc140-mt-1_58.lib” 问题

    注:本文为工作问题记录,有些还未搞清楚原理,请见谅. 借鉴了网上分享的资料,感谢. 错误 LNK1104 无法打开文件"libboost_filesystem-vc140-mt-1_58.l ...

  8. iis7mysql 链接不上_Win7 64位IIS7出现数据库链接出错的解决办法

    这个问题绝对困扰了大部分菜鸟网友,这里结合本人经验给大家归纳为两点,对,只需要两点,网上那么多复杂的办法都是多余的,只需要两点,绝对搞定一切问题. 方法一:开启父路径 在IIS7中ASP默认情况下,& ...

  9. win 2008 64位IIS7出现数据库链接出错的解决办法

    法一:开启父路径 在IIS7中ASP默认情况下,"父路径"是没有启用的,我们必须手动开启"父路径",选择"True",搞定"父路径 ...

  10. c++/ boost 库常见错误及解决方法总结

    c++/ boost 库常见错误及解决方法总结 参考文章: (1)c++/ boost 库常见错误及解决方法总结 (2)https://www.cnblogs.com/tyche116/p/93586 ...

最新文章

  1. react+dva+antd接口调用方式
  2. 数据结构-栈的顺序结构两种方式
  3. jQuery筛选器常用总结
  4. android emulator培训,android emulator(未完)
  5. 人工神经网络_人工神经网络实践
  6. 【Oracle】搭建DataGuard
  7. excel合并多个工作表_多个Excel工作表合并到一个工作簿
  8. Beyond Compare怎么查看合并文本后相同内容
  9. 在龙芯平台上编译jogamp(gluegen)
  10. 基台和种植体如何连接_种植牙所用的材料是什么?安不安全?种植牙手术后该如何护理?...
  11. css3 水纹效果(仿写阿里云)
  12. java中猜字母_Java有大神会写 猜字母游戏
  13. 黑群DS3617xs 6.2.3套件中心无法添加第三方源/添加第三方源失败解决方案/群晖套件中心无效的位置解决
  14. 大物 磁场对载流导线的作用 中dl转化为dx
  15. C#中调用OCX控件
  16. tensor如何实现转置_转置()TensorFlow中的函数
  17. js 控制字符串长度 区分中英文
  18. VSCode调试代码的三种方式
  19. Pandas、Numpy 性能优化秘籍(全)
  20. linux pdf翻译

热门文章

  1. c语言中如何确保一个程序是单例的_浅谈设计模式——单例模式
  2. GCD nyoj1007(欧拉函数运用数论入门)
  3. 打断点是什么意思_英语微课堂:“Give me a break”是什么意思呢?
  4. 【2019杭电多校第五场1006=HDU6629】string matching(求后缀字符串和本串的最长公共前缀长度之和--扩展kmp)
  5. java泛型的英文_Java泛型一:泛型的定义及规则
  6. Spring Boot 2.0 从入门到精通 From Zero to Hero with Spring Boot - Brian Clozel
  7. fluent设置uds c语言程序,FLUENT---UDS 计算流体停留时间(空气龄)
  8. 基于用户画像的商品推荐挑战赛
  9. CondaHTTPError: HTTP 000 CONNECTION FAILED for url ...... 解决过程
  10. python中的__file__、os.path.realpath(__file__)、os.path.dirname(os.path.realpath(__file__))