我编译我的代码,但失败了。
# g++ -g test.cpp -o test -lboost_filesystem
/tmp/cc5yybJZ.o(.text+0xb0): In function `__static_initialization_and_destruction_0':
/usr/local/include/boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_category()'
/tmp/cc5yybJZ.o(.text+0xbc):/usr/local/include/boost/system/error_code.hpp:215: undefined reference to `boost::system::generic_category()'
/tmp/cc5yybJZ.o(.text+0xc8):/usr/local/include/boost/system/error_code.hpp:216: undefined reference to `boost::system::system_category()'
/tmp/cc5yybJZ.o(.gnu.linkonce.t._ZN5boost10filesystem9file_sizeERKNS0_4pathE+0x19): In function `boost::filesystem::file_size(boost::filesystem::path const&)':
/usr/local/include/boost/filesystem/operations.hpp:447: undefined reference to `boost::filesystem::detail::file_size(boost::filesystem::path const&, boost::system::error_code*)'
collect2: error: ld returned 1 exit status
但是当我使用 -L/usr/local/lib 编译时它是成功的
g++ -g test.cpp -o test -lboost_filesystem -L/usr/local/lib
并且/usr/local/lib
已经配置在/etc/ld.so.conf
# cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/lib64
/usr/local/lib
/usr/local/mpc/lib
/usr/local/mpfc/lib
什么原因?
-L/libpath 和 /etc/ld.so.conf 配置 libpath 有什么区别?