From: Greg Chicares (chicares_at_[hidden])
Date: 2001-06-05 00:09:59
David Abrahams wrote:
> I am trying to understand how best to support shared libraries
> in the build system. Several people have mentioned to me that
> under GCC, DLL source files should be compiled with -fPIC.
Not on mingw, where a DLL is built this way:
Building a DLL:
$ gcc -c foo.c
$ gcc -shared -Wl,--implib,libfoo.a -o foo.dll foo.o
I just seached the mingw mailing list archives and found
no evidence of anyone using -fPIC.
According to the gcc online manual
Produce a shared object which can then be linked with
other objects to form an executable. Not all systems
support this option. You must also specify `-fpic' or
`-fPIC' on some systems when you specify this option.
Position-independent code requires special support,
and therefore works only on certain machines. For the
386, GCC supports PIC for System V but not for the Sun
386i. Code generated for the IBM RS/6000 is always
It appears that -fpic and -fPIC may be different, but I
can't say for sure. I've never experimented with this
so take what follows with a grain of salt--I'm just
reporting what I gleaned from a web search.
From the cygwin mailing list
> To recap, DO NOT use -fPIC/pic with egcs-1.1 if you
> don't want bad code.
That was the sollution! Thank you very much.
I found a patch, dated several months before that message,
that would have caused -fpic to be ignored, but I guess
it wasn't applied.
Also, I found a message on a BeOS list:
that suggests -fpic has a 10% speed penalty, although
the followups dispute it.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk