|
Boost : |
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:
ftp://ftp.nanotech.wisc.edu/pub/khan/gnu-win32/mingw32/snapshots/gcc-2.95.2-1/README
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
http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_2.html#SEC2
-shared
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.
-fpic
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
position-independent.
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
http://www.cygwin.com/ml/cygwin/1999-06/msg00329.html
> 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:
http://www.bespecific.com/dialog/bedevtalk/archive/981102/00000061.htm
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