[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dynamic libs example code

Jan Ekholm wrote:

> Hmm, I don't know what article you refer to, but making shared libraries
> is not difficult. Basically you need to make sure the code is compiled
> with the switch '-fpic' and the library is finally linked with the switch
> '-shared'. Such as:
> gcc -fpic -c Part1.c
> gcc -fpic -c Part2.c
> gcc -shared -o MyLib.so Part1.o Part2.o -lOtherNeededLib

I was wondering if anybody could illuminate me about those -fpic
flags... The man pages are quite cryptic about them. The libraries I
tried seems to work even *without* this flag (both in regular "-l" usage
and using dlopen), and anyway, what ARE "large displacement branches"
(the thing -fPIC is about)?

When should I use -fPIC rather than -fpic? Depends on the platform? Why
doesn't it make any difference when I do not use those flags?

Pierre Phaneuf
Ludus Design, http://ludusdesign.com/
"First they ignore you. Then they laugh at you.
Then they fight you. Then you win." -- Gandhi