ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi, I have a small problem. Considering 3 files: prog, liba.so, b.so in the same directory.
prog - program, which dlopens b.so
b.so - library, which is linked to the liba.so
liba.so - some library in user directory
All goes ok when I run it like this:
$ LD_LIBRARY_PATH=. ./prog
But I'd like to use only
$ ./prog
So before calling
dlopen("./b.so", RTLD_LAZY)
I set LD_LIBRARY_PATH:
setenv("LD_LIBRARY_PATH", ".", 1) /or putenv("LD_LIBRARY=.")/
But it didn't help. I successfully checked, if environment variable is set well via system("echo $LD_LIBRARY_PATH"). I watched strace and I can see there, that dlopen doesn't try to find liba.so in current directory.
paulsm4; Is this sort of what you are talking about (in the context of the binary using the lib)?:
1) remove calls to dlopen, etc.
2) #include a header file with the function declarations used from the shared lib
3) use the functions by name
4) -L the current path and -l the actual libs at link time
I'm not sure if that's what you were thinking of, but it just came to me when I looked through the LQ post you linked to. I suppose you would still need to use ldconfig or LD_LIBRARY_PATH, though.
ta0kira
paulsm4: Thanks, now it works exactly like I need. I guessed that it is somehow possible to store path to libraries in target ELF, but not found it. I looked once more to tldp.org and see the solution.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.