On Thu, Oct 25, 2001 at 09:46:06PM -0400, Dossy wrote: > On 2001.10.25, Andrew Piskorski <[EMAIL PROTECTED]> wrote: > > Unfortunately, the vendor of this > > closed-source API ships only the non-shared libfoo.a version of their > > library - they don't ship a libfoo.so. > > So, just make a libfoo.so that only consists of libfoo.a linked > in. > > gcc -shared -o libfoo.so -L/path/to/libfoo.a -lfoo > > Shouldn't this work?
Ah, I didn't know you could do that - thanks! But, when I try it, I'm running into problems I don't understand. I tried it a couple different ways: 1. Putting everything from libfoo.a and myfoo.c into a single myfoo.so library: $ gcc -shared -I../aolserver/include -g -fPIC -o myfoo.so myfoo.c /home/foo/lib/libfoo.a This fails to create myfoo.so, and spits out a single gigantic error messge: Text relocation remains referenced against symbol offset in file <unknown> 0x33a4 /home/foo/lib/libfoo.a(fooclient.o) malloc 0x30 /home/foo/lib/libfoo.a(fooarg.o) malloc 0x2868 /home/foo/lib/libfoo.a(fooarg.o) PQueDumpN 0x830 /home/foo/lib/libfoo.a(foopque.o) [ ... 12000 or so more lines of stuff ] ld: fatal: relocations remain against allocatable but non-writable sections collect2: ld returned 1 exit status Is this the dreaded "non-position-independent code" problem?? 2. Taking the vendor's libfoo.a, compiling that to libfoo.so, only, and then create my own separate myfoo.so library. $ gcc -shared -fPIC -o libfoo.so /home/foo/lib/libfoo.a I'd SWEAR that this was giving me the same "relocations remain against allocatable" error as above, but when I do it again now, libfoo.so is successfully created, but there's really nothing in it - the file is only 4 kb long, and "strings libfoo.so" gives no output. 3. Ok, some searching on the web led me to try the -mimpure-text switch with the "put everything into a single myfoo.so library" from step 1.: $ gcc -shared -fPIC -mimpure-text -I../aolserver/include -g -o myfoo.so myfoo.c /home/foo/lib/libfoo.a That seems to work, but oddly, compare "strings myfoo.so" and "strings libfoo.a", myfoo.so seems to be missing some stuff - they look like the names of functions - that libfoo.a has. Could be a red herring, I dunno. Then when I try to start up AOLserver, I get: [-main-] Warning: modload: failed to load '/web/aol3/bin/foo.so': 'ld.so.1: /web/aol3-src/aolserver/nsd/nsd8x: fatal: relocation error: file /web/aol3/bin/foo.so: symbol RegSetValueEx: referenced symbol not found' By running strings, I see that that symbol RegSetValueEx is in libfoo.a but NOT in myfoo.so. So I think it isn't linking correctly this way either. I am clueless on what to try next, so any advice would be greatly appreciated... -- Andrew Piskorski <[EMAIL PROTECTED]> http://www.piskorski.com