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
|
|