This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Linking a third-party library with my own library
- From: Axel Freyn <axel-freyn at gmx dot de>
- To: gcc-help at gcc dot gnu dot org
- Date: Sun, 8 Mar 2009 19:28:21 +0100
- Subject: Re: Linking a third-party library with my own library
- References: <001601c9a018$626204e0$27260ea0$@com>
Hi Rodrigo,
On Sun, Mar 08, 2009 at 02:04:54PM -0400, Rodrigo Dominguez wrote:
> g++ -shared [other switches] -L/path-to-libpapi [more switches] -lpapi -o
> mylibrary.so mylibrary.o
> The command executes without errors. However, when I run 'ldd mylibrary.o' I
> get:
> libpapi.so.3 => not found
>
> I can see that libpapi.so.3 exists under /path-to-libpapi. Needless to say,
> when I try to load my library it complains about not being able to find
> libpapi.so.3.
>
> What am I missing?
The compiler did its work correctly, however, as you use static linkage,
you have to tell "ldd" where to look for the library libpapi.so.3:
Either you can do it system-wide by changing /etc/ld.so.conf (on
linux), or by defining the environment-variable LD_LIBRARY_PATH
e.g. in bash,
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path-to-libpapi ldd mylibrary.o
should work (You could also use LD_LIBRARY_PATH=/path-to-libpapi,
however I repeated the $LD_LIBRARY_PATH for the case that this variable
had already been defined...)
HTH,
Axel