Suppose I have /a/lib/dir
that has files
-rwxrwxr-x libboost_signals.so
-rwxrwxr-x libboost_signals.so.1.55.0
And I create a file: /etc/ld.so.conf.d/testlib.conf
with content
/a/lib/dir
And run
sudo ldconfig
sudo ldconfig -v | head
libboost_signals.so.1.55.0 -> libboost_signals.so.1.55.0
Since ldconfig create a link libboost_signals.so.1.55.0
not libboost_signals.so
,
I can't use -lboost_signals
when use g++ to compile the source code.
But -L/a/lib/dir/ -lboost_signals
is ok.
Edit the .bashrc file as:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/a/lib/dir
then
source .bashrc
will be the same result.
So what is the correct way to add system LD_LIBRARY_PATH?
I can't use
-lboost_signals
when use g++ to compile the source code.But
-L/a/lib/dir/ -lboost_signals
is ok.
LD_LIBRARY_PATH
and /etc/ld.so.conf.d
control the behaviour of the run-time linker ld.so
only and do not affect the linking of the object files and libraries done by ld
, this is why -L/a/lib/dir/
must be used.
There is no config file or environment variable to add to ld
linker path. People normally hard-code extra linker paths in the makefile. Makefiles often consider LDFLAGS
environment variable though.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句