程序在运行时找不到 libboost_program_options.so.1.47.0
由于我没有 root 权限来安装 Boost C++ 库,所以我将其安装在我的本地本地目录下。编译时我使用了: 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
但在运行时,它会发生: 加载共享库时出错:libboost_program_options.so.1.47.0:无法打开共享对象文件:没有这样的文件或目录
并且 ldd 给出: libboost_program_options.so.1.47.0 => not find
我也尝试指定库的绝对路径,但它也不起作用: 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
Since I don't have root permission to install Boost C++ library, I installed it under my home local. When compiling, I used: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
but at runtime, it goes:error while loading shared libraries: libboost_program_options.so.1.47.0: cannot open shared object file: No such file or directory
and ldd gives:libboost_program_options.so.1.47.0 => not found
I also tried to specify the absolute path of the library, but it doesn't work either: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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用 LD_LIBRARY_PATH 环境变量来指示运行时链接器在哪里找到该库:
然后重新运行您的应用程序。
Try using the
LD_LIBRARY_PATH
environment variable to instruct the run-time linker where to find the library:Then rerun your application.
我是新手,所以不要太认真地对待我的话。此外,这个问题已经有几个月了,我想很久以前就解决了。尽管如此,这就是我的想法。
您指定链接器的库路径,以便程序可以正常编译和链接。但是,当您尝试执行二进制文件时,它会在环境定义的路径中查找库。
我想这可以通过输入 bash
export PATH=$PATH:path_to_your_library_folder
来解决最好的问候
米罗斯拉夫
I'm a newbie, so don't take my words too seriously. Furthermore, this question is several months old and I guess solved long ago. Nevertheless, here's what I think.
You specify the library path to the linker, so the program compiles and links fine. However, when you try to execute the binary, it looks for the libs in the environment defined path.
I guess this can be fixed by typing into bash
export PATH=$PATH:path_to_your_library_folder
Best Regards
Miroslav