蓝森林首页 | 返回主页 | 本站地图 | 站内搜索 | 联系信箱 |
 您目前的位置:首页 > 自由软件 > 技术交流 > 应用编程


    

蓝森林 http://www.lslnet.com 2006年6月6日 10:18


Can not load share libraries. 为什么?

在Linux下编译Boost.regex库, 在~/web/boost_1_31_0/libs/regex/build/gcc
下生成了 libboost_regex-gcc-1_31.so
编译测试程序
g++ boost_regex.cpp -I ~/web/boost_1_31_0 -L ~/web/boost_1_31_0/libs/regex/build/gcc -lboost_regex-gcc-1_31
正常.
运行 ./a.out
出错: ./a.out: error while loading shared libraries: libboost_regex-gcc-1_31.so: cannot open shared object file: No such file or directory

请问是什么原因?

Can not load share libraries. 为什么?

将libboost_regex-gcc-1_31.so所在的路径加到环境变量LD_LIBRARY_PATH中。

Can not load share libraries. 为什么?

非常感谢你!
设置了LD_LIBRARY_PATH后,运行成功了!

Can not load share libraries. 为什么?

问题有来了:
我装了ACE,
在 /etc/profile 里设置了 expert LD_LIBRARY_PATH=/opt/ACE...
这样我每次运行Boost.regex程序时, 必须要重新设定LD_LIBRARY_PATH为Boost的regex共享库的目录,当运行ACE程序时又得重新设定LD_LIBRARY_PATH路径...
有没有什么方法把两个不同的目录都设定成共享库的搜索路径?

Can not load share libraries. 为什么?

LD_LIBRARY_PATH=后面可以接续多个路径,路径之间用“:”分隔。例如,LD_LIBRARY_PATH=/opt/ACE:/your_regex_lib_path:$LD_LIBRARY_PATH。后面的$LD_LIBRARY_PATH表示原来已经设置的路径,这样就相当于在原来已设置好的路径之上又增加了/opt/ACE和/your_regex_lib_path两个路径。

Can not load share libraries. 为什么?

谢谢,谢谢 楼上的。。。。。

Can not load share libraries. 为什么?

Can not load share libraries. 为什么?

把库丢到 /usr/lib里面就可以了吧 省事:)

Can not load share libraries. 为什么?

都放到  /usr/lib 里头,有时感觉很乱。

Can not load share libraries. 为什么?

>;>; 都放到 /usr/lib 里头,有时感觉很乱。
对。不过这还是次要的。如果是自己的计算机,想怎么放都可以。可是如果是公用的,大部分用户可不是管理员,对/usr/lib没有写权限,想放也不是那么随便就能放的吧。

Can not load share libraries. 为什么?

一般可以放到 /usr/local/lib 里头, linux 好象默认搜索这个路径。

>;>;如果是自己的计算机,想怎么放都可以。

偶从来就是管理员,没考虑这么多,笑了。 :D

Can not load share libraries. 为什么?

我找了个 linux 看了一下,原来连 /usr/local/lib 也只有 root可写。 :oops:

Can not load share libraries. 为什么?

Can not load share libraries. 为什么?

regex用也有.a吧...



Copyright © 1999-2000 LSLNET.COM. All rights reserved. 蓝森林网站 版权所有。 E-mail : webmaster@lslnet.com