LINUX - linking archive (static library) with shared (dynamic) library
Hi all,
I want to create an archive from a bunch of object files that should be linked with an existing shared library. Meaning that I would like to link the archive with a shared library. Can it be done? If so - how can I do that? I'm working with GNU Linux 2.6. Thanks |
The object files themselves would need to be linked against the shared library, AFAIK.
|
Thanks Matir for your quick response.
However, I still don't get what you meant: When creating the objects there's no linkage - I only compile the c files into object files using implicit rule. How can I link the objects with a shared library as you kindly suggested? Thanks |
I believe you'd need to use:
Code:
gcc -shared -Wl,-soname,LIBNAME -o LIBNAME OBJFILES -lOTHERLIBRARY |
Quote:
Code:
ar r foo.a foo.o Code:
gcc -shared -Wl,-soname,libfoo.so.1 -o libfoo.so.1.0 foo.o What do I need to do to get the linux linker to see globals in foo.a? I tried a version script but either I got it wrong or I'm missing something. Ultimately I have two goals: 1) produce a .so from a .a 2) control which symbols are visible (i.e. global) in the .so FWIW, I'm coming from an AIX background where .a's work in this context and symbol visibilty can be controlled via .exp files. Any help would greatly be appreciated. Thanks. |
script to change static .a to a shared .so
can't say I know exactly what you're talking about but here is a site where the script below came from homes.esat.kuleuven.be/~gcc/shared_libraries.html
(Note this site also discusses stripping unwanted symbols out) # Converting a static to a shared library: #! /usr/bin/ksh -p # # Makes a shared library from a static one # static_library=$1; shared_library=$2 ld -shared -s -h /freeware/gcc/linux-i386/lib/{shared_library} -o ${shared_library:-${static_library%%a}so} -whole-archive ${static_library} I'm testing this script right now on an archive libmpeg3.a Quote:
|
All times are GMT -5. The time now is 09:32 PM. |