Boost logo

Boost :

From: Thomas Witt (witt_at_[hidden])
Date: 2001-06-05 01:56:27

On Monday 04 June 2001 22:55, you 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. Is there any reason not to compile all
> targets with -fPIC under GCC? Does it generate less-efficient code?

IIRC yes. As shared libs may be loaded at different base addresses for
different processes, PIC(Position Independent Code) is needed so that the
code sections from shared libs can be shared between the processes.

What PIC code gives you is basicly an additional level of indirection in
accessing symbols and data within the lib.

I am not 100% sure whether this holds for all platforms.

For further details see:

J.R. Levine "Linkers and Loaders"
ISBN 1-55860-496-0


Dipl.-Ing. Thomas Witt
Institut fuer Verkehrswesen, Eisenbahnbau und -betrieb, Universitaet Hannover
voice: +49(0) 511 762 - 4273, fax: +49(0) 511 762-3001

Boost list run by bdawes at, gregod at, cpdaniel at, john at