Adding gnu ld library search paths to the * end *

I know how to add the GNU ld library to the search path using the -Ldir option and use it extensively. But as far as I can tell from reading the gcc and ld manuals, there is no way to add a list of library search paths to the end .

The -L option adds a start, after which it searches for the default paths to the system library. But I want to add the look-here-if-you-can't-find-it-anywhwere-else path. Is there a way to do this with ld?

I can imagine a hacky-crap solution that extracts all the standard dir libraries (using -print-search-dirs) and adds them to the -L list of search engines in the desired order, ahead of their implied duplicates by default search paths ...

But there must be a better way ...

+4
source share
2 answers

I don’t think you can do exactly what you want. However, what if you force all the characters in the libraries that you include to be weak with the following ld flag:

  -weak_library path_to_library This is the same as listing a file name path to a library on the link line except that it forces the library and all ref- erences to it to be marked as weak imports. 

Thus, if other libraries are included with stronger characters, they override the characters in look-here-if-you-can't-find-it-anywhwere-else.so . If the libraries specified in LD_LIBRARY_PATH do not have stronger characters defined in LD_LIBRARY_PATH , the weak characters in look-here-if-you-can't-find-it-anywhwere-else.so .

0
source

The file /etc/ld.so.conf has a system-wide list of paths to directories in which libraries are executed at compile time, the order of writing this type of record on a new line is respected.

After modifying this file, you must run ldconfig (as root) for the new parameter to become active.

0
source

All Articles