This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: library


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]