Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I change LD_LIBRARY_PATH after program start?

Status
Not open for further replies.

cheerful

Programmer
Mar 4, 2003
173
0
0
US
I would want to dlopen a library, which in turn, depends on some other libraries. I tried to change LD_LIBRARY_PATH in main before calling dlopen but it failed. It appears thath LD_LIBRARY_PATH is read only on start up. Is there any way to inform loader that it has changed?

Thanks!
 
No but you can try an absolute path to dlopen
 
That won't help since lib a also depends on lib b, which is not in LD_LIBRARY_PATH either.
 
Hi,
Why not load Library b first and then load library a using Absolute path names for both opens.

---
 
No, can't work that way.

lib a requires b, but that is ONLY required by a, nothing else in the program. From the program point of view, b is NOT needed.
 
man dlopen said:
External references in the library are resolved using the libraries in that library's dependency list and any other libraries previously opened with the RTLD_GLOBAL flag. If the executable was linked with the flag "-rdynamic", then the global symbols in the executable will also be used to resolve references in a dynamically loaded library.

So if you can [tt]dlopen[/tt] Library B with [tt]RTLD_GLOBAL[/tt], Library A should resolve its references using Library B's symbols.
 
My problem is:

I DO NOT know I need B. It is lib A that needs B. So I will only attempt to load A, NOT B.

It is possible to hard code B's location when building A. But that defeat the purpose of dynamic libraries.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top