Axel Freyn wrote: > Hi Rodrigo, > On Mon, Mar 09, 2009 at 10:53:08PM -0400, Rodrigo Dominguez wrote: >> [...] >> 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): > Sorry, it was a typing mistake from me - you using dynamic linkage (I > wanted to say "not using static linkage", but omitted "not"...) >> 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)? > As far as I know, there is no other way. As the idea behind dynamic > linkage is, that the code links the library files at runtime, no > pathes to the libraries are integrated into compiled code (otherwise, it > would be impossible to transfer a compiled library to another machine > where the libraries are stored in another directory...). That's right. > My solution to this problem is usually: > - for libraries, which I use very often: > * on machines where I'm root: changing ld.so.conf > * on machines where I'm only user: redefining LD_LIBRARY_PATH in my .profile. > - for rarely-used libraries: I start the program not directly from > command line, but using a shell script which defines LD_LIBRARY_PATH > accordingly You can use -rpath, but most people avoid this because it means you can't move libraries around. Andrew.