网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

boost库链接出错怎么办

这篇文章将为大家详细讲解有关boost库链接出错怎么办,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

萨尔图网站制作公司哪家好,找创新互联!从网页设计、网站建设、微信开发、APP开发、自适应网站建设等网站项目制作,到程序开发,运营维护。创新互联公司2013年成立到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联

安装完最新的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  

否则会报错:

errorwhile 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的值

这样才能正确识别动态库

关于“boost库链接出错怎么办”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。


网页题目:boost库链接出错怎么办
路径分享:http://bjjierui.cn/article/ippdso.html

其他资讯