由于我没有安装 Boost C++ 库的 root 权限,所以我将它安装在我的本地本地下。编译时,我使用了:
g++ -I/home/name/local/boost_1_47_0 -L/home/name/local/boost_1_47_0/stage/lib foo.cc -o foo -lboost_program_options
但在运行时,它会:
error while loading shared libraries: libboost_program_options.so.1.47.0: cannot open shared object file: No such file or directory
并且 ldd 给出:
libboost_program_options.so.1.47.0 => not found
我还尝试指定库的绝对路径,但它也不起作用:
g++ /home/name/local/boost_1_47_0/stage/lib/libboost_program_options.so.1.47.0 -I/home/name/local/boost_1_47_0 -L/home/name/local/boost_1_47_0/stage/lib foo.cc -o foo