RE: Linking a third-party library with my own library

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Axel,

> -----Original Message-----
> From: Axel Freyn [mailto:axel-freyn@xxxxxx]
> Sent: Sunday, March 08, 2009 2:28 PM
> To: gcc-help@xxxxxxxxxxx
> Subject: Re: Linking a third-party library with my own library
> 
> 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...)
> 

LD_LIBRARY_PATH works as you mentioned. Is this error happening because I am
using
static linkage (-lpapi)? I tried using dynamic linkage (libpapi.so):

g++ -shared [other switches] -o mylibrary.so mylibrary.o
/path-to-libpapi/libpapi.so

but I get the same problem. Is this the right way to do dynamic linkage? Is
there a 
way to make it work without having to set LD_LIBRARY_PATH (or
/etc/ld.so.conf)?

> 
> HTH,
> 
> Axel

Thanks for your help,

Rodrigo



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux