help-gplusplus
[Top][All Lists]
Advanced

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

Re: .so and .a libraries


From: Robert Heller
Subject: Re: .so and .a libraries
Date: Thu, 12 Aug 2004 00:23:30 +0200

  "Morusaka" <morusaka@inwind.it>,
  In a message on Wed, 11 Aug 2004 19:51:58 GMT, wrote :

"> Hi,
"> 
"> I have the same library (Boost Regex++ library) compiled both as a ".so" and
"> as a ".a" file.
"> I think .so means "shared object", is this right?
"> 
"> I am trying to compile some examples, with a sintax like:
"> 
"> g++ -IpathDirectory -LlibraryDirectory -llibraryName sourcefilename.cpp
"> 
"> it seems to compile right, but when I try to execute the program, my RedHat
"> system says it can't find the shared library.

I take it 'libraryDirectory' is not one of the directories configured
into ldconfig.

You have two options:

1) Embed the libraryDirectory in your executable:

g++ -IpathDirectory -LlibraryDirectory -Lrpath=libraryDirectory -llibraryName 
sourcefilename.cpp

2) Use the LD_LIBRARY_PATH environment variable:

export LD_LIBRARY_PATH=libraryDirectory

"> 
"> How can I link to my executable the ".a" library files?


g++ -static -IpathDirectory -LlibraryDirectory -llibraryName sourcefilename.cpp

I think.  I am not sure if you really want to do this -- you will likely
get a *huge* executable, since it is likely to link ALL of the system
libraries statically.  Try the above two options first.  The second can
be done right away, just set the LD_LIBRARY_PATH environ variable to the
directory where the .so file lives and then run the program.

Oh, you *could* also copy the .so file to /usr/local/lib and make sure
/usr/local/lib is in /etc/ld.so.conf and re-run /sbin/ldconfig (as
root).  This will make the .so file visible to the run-time loader,
automagically. 

"> 
"> Thank you in advance, Morusaka.
"> 
"> 
"> 
">                                                                              
                  

                                     \/
Robert Heller                        ||InterNet:   heller@cs.umass.edu
http://vis-www.cs.umass.edu/~heller  ||            heller@deepsoft.com
http://www.deepsoft.com              /\FidoNet:    1:321/153






                                                                                
       


reply via email to

[Prev in Thread] Current Thread [Next in Thread]