由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - Linux loading dynamic library problem
相关主题
what kind of reason might cause this problem? c++ 两个库接口冲突
Can LGPL, Boost library be used in commercial software developing?error while loading shared libraries
问个dynamic link library相关问题how to resolve this problem?
请教,关于g++ -l的问题use intel mkl with Xcode 3.1.1
一个奇怪的library linking问题(c++, boost.python, shared li (转载)编译通过 运行时出现 error while loading shared libraries 是哪的问题?
dummy question on math libraryA link issue in Android build
请大家帮忙看一下:关于AJAX 中加入“Pleas wait... ” messagesocket re-connection problem
gcc 4.3(or +) on Mac OS 10.6a question of perl
相关话题的讨论汇总
话题: libncurses话题: dlopen话题: library话题: dynamic
进入Programming版参与讨论
1 (共1页)
c*****t
发帖数: 1879
1
I wanted to add readline support to a command line app, but this program
could be run on machine without both libreadline and libncurses installed.
libreadline depends on libncurses to work.
If I do a dynamic link with these two libraries, the code would not run
on machines without either installed.
If I do dlopen on libreadline, it gave me error since it could not resolve
some global variables only found in libncurses.
Any ideas?
t****t
发帖数: 6806
2
assuming the version you "bring on" is correct, check whether you set LD_
LIBRARY_PATH correctly (e.g. include ".") to let dynamic link work.
alternatively, you may use -rpath in ld to "append" a path to LD_LIBRARY_
PATH. this is supported by ELF. for linking with gcc, use -Wl,-rpath -Wl,
your_own_path.

【在 c*****t 的大作中提到】
: I wanted to add readline support to a command line app, but this program
: could be run on machine without both libreadline and libncurses installed.
: libreadline depends on libncurses to work.
: If I do a dynamic link with these two libraries, the code would not run
: on machines without either installed.
: If I do dlopen on libreadline, it gave me error since it could not resolve
: some global variables only found in libncurses.
: Any ideas?

c*****t
发帖数: 1879
3
The problem is, some machines do not have libreadline and libncurses
installed in the first place.
So I would like to switch to defaults fget routine instead of calling
readline if the target machine does not have either installed.

【在 t****t 的大作中提到】
: assuming the version you "bring on" is correct, check whether you set LD_
: LIBRARY_PATH correctly (e.g. include ".") to let dynamic link work.
: alternatively, you may use -rpath in ld to "append" a path to LD_LIBRARY_
: PATH. this is supported by ELF. for linking with gcc, use -Wl,-rpath -Wl,
: your_own_path.

t****t
发帖数: 6806
4
哦, 你要看ld.so是不是失败啊.
那首先不能dynamic link, 据我所知失败了是没有hook的. 只能dlopen.
我没试过dlopen libreadline, 什么错误信息?
我两年前试过libreadline, 发现用起来好麻烦, end up with wrote my own version.
..

【在 c*****t 的大作中提到】
: The problem is, some machines do not have libreadline and libncurses
: installed in the first place.
: So I would like to switch to defaults fget routine instead of calling
: readline if the target machine does not have either installed.

w***g
发帖数: 5958
5
最好用static link. Linux版本太多, 如果想只deliver binary, 一要找一个老版本
的kernel, 二要static link所有的library. readline这种东西自己编译一个static版
本就可以了. 我最近在做的一个事情才扯淡. 对方要一个.so的binary. 但是
dependency一大堆, 结果是把所有要用到的library全都static link到这个.so中. 但
是这个.so本身又需要能被动态链接, 结果大部分的library还需要用-fPIC重新编译.
做完之后我很惊异于gnu这套toolchain的flexibility.

【在 c*****t 的大作中提到】
: I wanted to add readline support to a command line app, but this program
: could be run on machine without both libreadline and libncurses installed.
: libreadline depends on libncurses to work.
: If I do a dynamic link with these two libraries, the code would not run
: on machines without either installed.
: If I do dlopen on libreadline, it gave me error since it could not resolve
: some global variables only found in libncurses.
: Any ideas?

c*****t
发帖数: 1879
6

dlopen reports errors of missing global variables like BC, which is
actually located in libncurses.
I tried to dlopen libncurses first with dlopen, but it did not work.
version.

【在 t****t 的大作中提到】
: 哦, 你要看ld.so是不是失败啊.
: 那首先不能dynamic link, 据我所知失败了是没有hook的. 只能dlopen.
: 我没试过dlopen libreadline, 什么错误信息?
: 我两年前试过libreadline, 发现用起来好麻烦, end up with wrote my own version.
: ..

b*****e
发帖数: 474
7
try tecla for command line stuff.
Or, try static linking.
For dlopen, maybe you should do RTLD_GLOBAL for libncurses

【在 c*****t 的大作中提到】
: I wanted to add readline support to a command line app, but this program
: could be run on machine without both libreadline and libncurses installed.
: libreadline depends on libncurses to work.
: If I do a dynamic link with these two libraries, the code would not run
: on machines without either installed.
: If I do dlopen on libreadline, it gave me error since it could not resolve
: some global variables only found in libncurses.
: Any ideas?

c*****t
发帖数: 1879
8

Thanks, I will try that.

【在 b*****e 的大作中提到】
: try tecla for command line stuff.
: Or, try static linking.
: For dlopen, maybe you should do RTLD_GLOBAL for libncurses

1 (共1页)
进入Programming版参与讨论
相关主题
a question of perl一个奇怪的library linking问题(c++, boost.python, shared li (转载)
Dynamic buffer management questiondummy question on math library
python gc question请大家帮忙看一下:关于AJAX 中加入“Pleas wait... ” message
版上有人用Lisp么?gcc 4.3(or +) on Mac OS 10.6
what kind of reason might cause this problem? c++ 两个库接口冲突
Can LGPL, Boost library be used in commercial software developing?error while loading shared libraries
问个dynamic link library相关问题how to resolve this problem?
请教,关于g++ -l的问题use intel mkl with Xcode 3.1.1
相关话题的讨论汇总
话题: libncurses话题: dlopen话题: library话题: dynamic