LD_PRELOAD changes the LD_LIBRARY_PATH
I am having a peculiar problem. I have a shared library 'my_tracker.so' that I built using gcc-4.2. This shared library now has a dependency on libgcc_s.so.1 (GCC 4.2). I did 'ldd my_tracker.so' and it picked up libgcc_s.so.1 from /lib64.
I am running the
'LD_PRELOAD=my_tracker.so LD_LIBRARY_PATH=[vnc_install]/lib/vnclibs:$LD_LIBRARY_PATH vncserver'
inside my script. I want to make sure the vncserver gets its libgcc_so.1 (GCC 3.2.3) from the [vnc_install]/lib/vnclibs/
and hence put it in front of LD_LIBRARY_PATH
.
However,after executing my script, it looks like the vncserver is picking up libgcc_s.so.1 (GCC 4.2) from /lib64
.
Does the loading of my pre-loaded shared library 'my_tracker.so' prepend 开发者_运维知识库the LD_LIBRARY_PATH
with where libgcc_s.so.1 (GCC 4.2) was found?
If so, how can I fix this issue?
Regards John
The solution to this is to get patchelf
and use it to patch your binary, and any copied libraries, to use RPATH. Then you can ignore LD_LIBRARY_PATH entirely. And if you need a different ld-linux.so to load your binary, patchelf
can fixup the binary to find that as well.
精彩评论