开发者

why after setting LD-LIBRARY_PATH and ld.so.cache properly, there are still library-finding problems?

I have a certain shared object library in a special directory which I

  • make sure special directory is in $LD_LIBRARY_PATH
  • make sure this directory has read and execute permisions for all
  • make sure appropriate library directory is in ld.so.conf and that root has done a ldconfig (verify by checking for library using ldconfig -p as normaluser.
  • make sure it is has no soname problems (i.e. create a few symlinks if necessary)

Now, say I compile a program that needs that special library, a program packaged in a typical Open Source manner which ./configure && make, etc) and it says -lspecialibrary cannot be found, an error which a lack of any of the above checks would also probably throw.

A workaround I have done is to symlink the library to /usr/local/lib64 and suddenly the library has ben found. Also when compiling a relatively simple package, I manually add -L/path/to/spec/lib and that also has worked. But I regard those two methods as hacks,开发者_运维问答 so I was looking for any clues as to why my list of checks aren't good enough to find a library.

(I particularly find the $LD_LIBRARY_PATH of shallow use. In fact I can exclude certain libraries from it, and they will still be found in a compilation process).


$LD_LIBRARY_PATH and ldconfig are only used to locate libraries when running programs that need libraries, i.e. they are used by the loader not the compiler. Your program depends on libspeciallibrary.so. When running your program $LD_LIBRARY_PATH and ldconfig are consulted to find libspeciallibary.so.

These methods are not used by your compiler to find libraries. For your compiler, the -L option is the right way to go. Since your package uses the autotools, you should set the $LDFLAGS environment variable:

LDFLAGS=-L/path/to/lib ./configure && make

This is also documented in the configure help:

./configure --help
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜