-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
>I am trying to compile a shared object library using the -shared option
>with gcc 2.7.2.1 on a linux machine. It gives me a segmentation fault.
What does, gcc, or your application?
If your app gets a segmentation fault, the problem may be that
you forgot to compile your library with `-fpic'.
>Is it possible to create a shared object library on linux with gcc?
Yes. The method is documented in the HOWTO for ELF, I think.
--
Fergus Henderson | Designing grand concepts is fun;
f...@cs.mu.oz.au | finding nitty little bugs is just work.
http://www.cs.mu.oz.au/~fjh | -- Brooks, in "The Mythical Man-Month".
PGP key fingerprint: 00 D7 A2 27 65 09 B6 AC 8B 3E 0F 01 E7 5D C4 3F
The attached document contains everything you need to know about creating
and using shared libs under Linux (and Solaris); this is taken directly from
the ELF HOWTO with a few edits/additions by yours truly.
The steps involved in doing a shared library:
1) cat lfoo.c
hello() { puts("hello, world"); }
2) gcc -fPIC -c lfoo.c
3) gcc -shared -Wl,-soname,libfoo.so.1 -o libfoo.so.1.0 lfoo.o
3a) Note: To do the same thing on the Sun (Solaris), use the native ld, thusly:
ld -G -h libfoo.so.1 -o libfoo.so.1 lfoo.o
4) ln libfoo.so.1.0 libfoo.so.1;ln libfoo.so.1.0 libfoo.so
5) cat bar.c
extern hello();
main() { hello(); }
6) gcc -s -o bar bar.c -L. -lfoo
7) sh -c 'LD_LIBRARY_PATH=. ./bar'
hello, world
************************************************************************
My version of Shakespeare, as applied to traffic safety:
First thing we do is kill all the cabdrivers!
- py...@quads.uchicago.edu, who is still costing the net
hundreds, if not thousands, of dollars, every time he posts -
************************************************************************
rwvpf wpnrrj ibf ijrfer