This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Correct way of linking with a shared library?
- To: egcs at egcs dot cygnus dot com
- Subject: Correct way of linking with a shared library?
- From: Johann Petrak <johann at ai dot univie dot ac dot at>
- Date: Thu, 17 Dec 1998 15:02:32 +0100
- Organization: OFAI
Up to now I used to link the executable against a shared
library on a SunOS 4.1.4 system with egcs-1.1 such:
g++ exestuff.o -L. -lSHLIB -lstdc++ -o exestuff
where libSHLIB.so.1.0 is the library I have previously
generated. This worked fine.
On a SunOS 5.6 system with egcs-1.1.1 I keep getting the
message
ld: fatal: library -lSHLIB: not found
Sometimes, replacing SHLIB with SHLIB.1.0 works, but
sometimes it doesnt.
I found, however, that doing
g++ exestuff.o libSHLIB.so.1.0 -lstdc++ -o exestuff
DOES work (The manual gcc.info-1 says that one can use an object
file in place of a (static) library with the -l option,
and this seems to indicate
that one can specify a library in the same way as
an object file ... is this correct?)
I am pretty sure, that the method using -lSHLIB
should work, so what could be the problem here?
Another question: if I try to include the version number
on the SunOS4.1.4 system:
g++ exestuff.o -L. -lSHLIB.1.0 -lstdc++ -o exestuff
I get the error message:
collect2: dynamic dependency libSHLIB.1.0.so.1.0 not found
So how can I explicitly specify against what version of
dynamic library to link, if there is more than one?
Related to this: how can I explicitly record a certain
run-time dependancy in the executable, i.e. if I link
against libSHLIB.so but want to record the dependancy
libSHLIB.so.2.3, how can I achieve this?
Many thanks for any help on these questions ...
Johann
Johann Petrak Email: johann@ai.univie.ac.at
Austrian Research Institute for AI Phone: +43-1-533-61-12/13
Schottengasse 3 Fax: +43-1-532-61-12/77
A-1010 Vienna, AUSTRIA http://www.ai.univie.ac.at/~johann