From: Thomas Matelich (sosedada_at_[hidden])
Date: 2001-06-04 17:55:29
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. Is there any reason not to compile all
> targets with -fPIC under GCC? Does it generate less-efficient code? If it's
> important to be able to build some targets without -fPIC, it's clear to me
> that we need a way of expressing constraints that a target type places on
> its build configuration. Also, I assume this constraint is transitive, at
> least on any targets that are /statically/ linked to the shared library.
> Please enlighten.
I can't give you a canonical answer, but I'll share what I know. A shared
library must be built with PIC object files. Anything can be built with PIC
code, but linking will be slower for static entities than if you didn't have
PIC. I can't remember if PIC code runs slower, but I don't think so.
Regarding your transitive assumption, things are peculiar. On Linux (ELF
format), a shared library can link in a static library even if the static
library was not built PIC. On HP-UX (not ELF), anything linked into a shared
library must be build PIC. So, it is tempting to build everything PIC because
of platforms like HP-UX.
I would have expected Jam to have already figured this stuff out. If you're in
the mood to look at a different build system, you could get tmake from
ftp.trolltech.com/pub/freebies/tmake. They have a hierarchical system of rules
regarding building apps and libs on many platform-compiler combinations.
Alternatively, qmake (c++ implementation) is bundled into the qt 2.30 beta and
adds support for Mac.
I was going to suggest boost look at qmake, but I don't know if they go as far
with things like debug and release. Otherwise, their .pro file format is quite
-- Thomas O Matelich Senior Software Designer Zetec, Inc. sosedada_at_[hidden] tmatelich_at_[hidden]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk