library

Scott Robert Ladd coyote@coyotegulch.com
Wed May 14 14:31:00 GMT 2003


LaczĂł Tibor wrote:
> How can I make a shared library file, from objects files (.o) which
> program should i use, with which flags?

Compile your .c source files with the -fPIC option:

gcc -c -fPIC -o snafu.o snafu.c

This generates "Position Independent Code", ready for inclusion in a
shared object library using a command like:

gcc -shared -fPIC -o libfu.so snafu.o fubar.o

That syntax informs the linker to generate a shared library (without
-shared, it creates an executable image).


-- 
Scott Robert Ladd
Coyote Gulch Productions (http://www.coyotegulch.com)
Professional programming for science and engineering;
Interesting and unusual bits of very free code.



More information about the Gcc mailing list