ldconfig only links files starting with lib*?

2020-03-26 05:46发布

问题:

I'm struggling to make MVTec Halcon 11 work on Ubuntu. Everything is in the right place but the program doesn't see the dynamic libraries needed for image acquisition (the cameras alone work fine, the driver is installed)

I added the path with the libraries to /etc/ld.so.conf and ran ldconfig -v but of the 28 files present in the directory (all "Shared Library" type and .so extension), only the "lib*.so" ones are linked. As a matter of fact, ALL the libraries in the output of ldconfig are called lib*something.

Oddly, if I add "lib" in front of the name of the files, they get linked (of course that wouldn't be alright with the software)

Why is that?

回答1:

From the man of ld.so and ld-linux.so

Section FILES :

lib*.so* shared libraries

And from glibc (./elf/ldconfig.c) :

 712       /* Does this file look like a shared library or is it a hwcap
 713          subdirectory?  The dynamic linker is also considered as
 714          shared library.  */
 715       if (((strncmp (direntry->d_name, "lib", 3) != 0
 716             && strncmp (direntry->d_name, "ld-", 3) != 0)
 717            || strstr (direntry->d_name, ".so") == NULL)
 718           && (
 719 #ifdef _DIRENT_HAVE_D_TYPE
 720               direntry->d_type == DT_REG ||
 721 #endif
 722               !is_hwcap_platform (direntry->d_name)))
 723         continue;

Looks like you must choose a name begining with lib... The libc uses this to determine if the file may be a shared library.