国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C > 正文

快速解決boost庫鏈接出錯的問題(分享)

2020-01-26 14:08:33
字體:
來源:轉載
供稿:網友

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

這樣才能正確識別動態庫

以上這篇快速解決boost庫鏈接出錯的問題(分享)就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 防城港市| 固阳县| 宁化县| 大名县| 光山县| 霍邱县| 永定县| 全南县| 巫溪县| 封丘县| 河津市| 南开区| 临沭县| 阜平县| 定南县| 噶尔县| 连州市| 神池县| 温宿县| 健康| 渭南市| 图木舒克市| 内丘县| 凤城市| 临海市| 乳源| 台北市| 印江| 青龙| 阿城市| 温州市| 葵青区| 车致| 鹤峰县| 磐石市| 抚顺市| 麻江县| 博爱县| 建湖县| 修水县| 迁安市|