我已經安裝libboost-dev
到apt-get
,它被放置在/usr/lib
。我安裝了libboost,但無法鏈接到它
/usr/lib$ ls | grep boost
libboost_filesystem.so.1.46.1
libboost_iostreams.so.1.46.1
libboost_serialization.so.1.46.1
libboost_system.so.1.46.1
libboost_thread.so.1.46.1
libboost_wserialization.so.1.46.1
但是,當我試圖編譯使用boost_thread
我還是有一個錯誤。
$ g++ tcp_echo.cpp -o tcp_echo -L/usr/lib -llibboost_thread
/usr/bin/ld: cannot find -lboost_thread
collect2: ld returned 1 exit status
$ g++ tcp_echo.cpp -o tcp_echo -L/usr/lib -lboost_thread
/usr/bin/ld: cannot find -lboost_thread
collect2: ld returned 1 exit status
什麼是安裝和鏈接到libboost
的正確方法?
您不需要'-L/usr/lib',它會自動添加到庫搜索路徑中。 –
您是否在安裝後嘗試過運行'ldconfig'(以root身份)? –
@JoachimPileborg ldconfig應該由apt運行,所以他應該很好。特別是如果使用'-L'的話。 – robert