LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Shared Object Cache not registering links (https://www.linuxquestions.org/questions/programming-9/shared-object-cache-not-registering-links-4175627889/)

SpectralMemories 04-17-2018 10:11 PM

Shared Object Cache not registering links
 
Hello,
I have a .so file that is successfully cached by ldconfig. It came with a link file pointing to it, so now there is two cache entry pointing to the same file. Great. But now, I tried to create another link, but this time it simply does not get cached. I tried to copy the already cached link and rename it, nothing. Am I missing something here? How do you create links to your library and get them cached by ldconfig?

Thanks, I am stuck with this since last friday

Alex

NevemTeve 04-17-2018 10:43 PM

What is the actual error message you get?

SpectralMemories 04-18-2018 07:18 AM

Absolutely none, thats whats the most annoying. I create the link via "ln -fs somefile.so alternativename.so", and upon using ldconfig -v, it does not output error, nor does it even try to register my link. If I rename the other link that came with the library, it gets removed from cache, and if I put it back, its cached again, like it should do. It seems my link is simply not a valid link to the ldconfig. I copied the valid link as much as possible, but it still won't register. Furthermore, this topic seems very obscure and I cannot find any ressource on that problem. Thanks for your reply

NevemTeve 04-18-2018 07:50 AM

The bit you might have ignored is DT_SONAME attribute of the shared object. That's what matters for ldconfig, not the filename. Test:
Code:

$ readelf -d /usr/local/lib64/libcpotlas.so | grep SONAME
 0x000000000000000e (SONAME)            Library soname: [libcpotlas.so.1]


SpectralMemories 04-18-2018 08:01 AM

Ok big thank you, this is valuable information. Do you know then why the linker forgot the link when I renamed it to something else? Does the soname have to match the filename to be linked? And if its quick to explain, how does one change the soname of a link?
Again, thank you, I needed to know that

Alex

NevemTeve 04-18-2018 08:16 AM

Well, you could quote the commands you used to create the shared lib. Here is an example using libtool:
Code:

libtool --mode=compile gcc -c rutin.c
libtool --mode=link gcc -shared -version-number 0:0:1 -o librutin.la -rpath ~/lib rutin.lo
libtool --mode=install cp librutin.la ~/lib/
libtool --mode=link gcc main.c -o main ~/lib/librutin.la



All times are GMT -5. The time now is 08:50 AM.