[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: .so and .a libraries
From: |
Paul Pluzhnikov |
Subject: |
Re: .so and .a libraries |
Date: |
11 Aug 2004 19:40:25 -0700 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Artificial Intelligence) |
Robert Heller <heller@deepsoft.com> writes:
> "Morusaka" <morusaka@inwind.it>,
> "> g++ -IpathDirectory -LlibraryDirectory -llibraryName sourcefilename.cpp
This command-line is "backwards"; libraries should always *follow*
objects and sources, never preceed them:
g++ -IpathDirectory source.cpp -L... -l...
> You have two options:
Five options:
> 1) Embed the libraryDirectory in your executable:
>
> g++ -IpathDirectory -LlibraryDirectory -Lrpath=libraryDirectory -llibraryName
> sourcefilename.cpp
Correction: make that
g++ -IpathDirectory source.cpp -Wl,-rpath=libraryDirectory -L... -l...
> 2) Use the LD_LIBRARY_PATH environment variable:
3) Add libraryDirectory to the /etc/ld.so.conf and run /sbin/ldconfig.
4) Link against the archive version of the library:
g++ -I... source.cpp /path/to/library.a
or
g++ -I... source.cpp -L/path/to -Wl,-Bstatic -llibraryName -Wl,-Bdynamic
> "> How can I link to my executable the ".a" library files?
See the 2 commands above.
> g++ -static -IpathDirectory -LlibraryDirectory -llibraryName
> sourcefilename.cpp
The above -- linking completely static executable -- is extremely bad idea(TM).
> 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.
Not only that, but your executable will likely break if/when you
move it to machines with newer versions of glibc [dynamically-linked
executables generally continue to work fine under these conditions].
5)
> 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.
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.