There is a laptop on which I have no root privilege.
onto the machine I have a library installed using configure --prefix=$HOME/.usr
.
after that, I got these files in ~/.usr/lib
:
libXX.so.16.0.0
libXX.so.16
libXX.so
libXX.la
libXX.a
when I compile a program that invokes one of function provided by the library with this command :
gcc XXX.c -o xxx.out -L$HOME/.usr/lib -lXX
xxx.out was generated without warning, but when I run it error like this was thrown:
./xxx.out: error while loading shared libraries: libXX.so.16: cannot open shared object file: No such file or directory
, though libXX.so.16
resides there.
my clue-less assumption is that ~/.usr/lib
wasn't searched when xxx.out is invoked.
but what can I do to specify path of .so , in order that xxx.out can look there for .so file?
An addition is when I feed -static
to gcc, another error happens like this:
undefined reference to `function_proviced_by_the_very_librar'
It seems .so
does not matter even though -L
and -l
are given to gcc.
what should I do to build a usable exe with that library?
For other people who has the same question as I did
I found a useful article at tldp about this.
It introduces static/shared/dynamic loaded library, as well as some example code to use them.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…