[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Linking static lib into shared lib
From: |
roman schindlauer |
Subject: |
Linking static lib into shared lib |
Date: |
Sat, 09 Jul 2005 14:39:42 +0200 |
User-agent: |
Mozilla Thunderbird 0.8 (X11/20040913) |
Hello all,
I am trying to produce a shared library, which should be linked to a
static lib itself, but haven't managed so far. I compiled raptor (lib
for rdf processing) out of the box, which gave me both static
(libraptor.a) and shared libs (libraptor.so.1). Now I am building a
shared lib (librdf) that uses libraptor. the final application that uses
this shared lib should only need this one, but not libraptor:
mystuff + static libraptor = librdf, shared lib, 'self-contained'
I did this to produce the shared lib:
g++ -Wall -g -c -fPIC rdfInterface.c -o rdfInterface.o
g++ -Wall -g -c -fPIC extTypes.c -o extTypes.o
g++ -g -shared -Wl,-soname,librdf.so.1 rdfInterface.o \
extTypes.o -lz -lm -L. -lraptor -o librdf.so.1.0
(assuming that libraptor.a is in the working dir)
This results in the following error:
/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.4/../../../../x86_64-suse-linux/bin/ld:
./libraptor.a(raptor_parse.o): relocation R_X86_64_32S against `a local
symbol' can not be used when making a shared object; recompile with -fPIC
./libraptor.a: could not read symbols: Bad value
(What does -shared actually mean: that it PRODUCES a shared lib or that
the linker should LINK dynamically to the specified libs? Then, what is
-static?)
If I remove the libraptor.a from the working dir and put all the
libraptor.so* there, everything works. librdf.so.1.0 is produced and
used by some example application, wich is compiled as follows:
g++ -Wall -g -c rdftest.c -o rdftest.o
...
g++ -g -Wl,-rpath,. rdftest.o extTypes.o extInterface.o -ldl -o \
rdftest
But then again, I need not only my librdf but also libraptor in the
directory of the executable, which I want to avoid!
Who can help?
Thnxia,
Roman
- Linking static lib into shared lib,
roman schindlauer <=