This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Building libstdc++ non-shared with -fpic ?
- To: lundril at gmx dot net
- Subject: Re: Building libstdc++ non-shared with -fpic ?
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Fri, 30 Jun 2000 19:02:37 +0200
- CC: gcc at gcc dot gnu dot org
- References: <20000630162046.A15548@flashline.chipnet>
> I complained about this to some folks (e.g. the Mozilla team),
> and said that gcc doesn't even build libstdc++ as shared library
> when build with the default configuration.
Yes, it is not the default, because if it was, it might not work in
the end - applications may not find libstdc++.so, when it is not on
the LD_LIBRARY_PATH. So administrators have to locally arrange that
everybody will find the shared libraries, therefore it is an
administrative decision. On Linux, gcc is normally installed into
/usr, in which case it is safe to activate --enable-shared; most
distributors do.
> Now if you try to build a shared library, which uses code of a
> static libstdc++, this will lead to problems, because the
> static libstdc++ will contain code which is NOT position
> independent.
No, it won't lead to problems - at least not if these two library
copies had the same source code, and where compiled by the same
compiler release. You can certainly combine non-PIC code into a shared
library, at least on Linux.
> A resolution to this problem seems to compile libstdc++ as
> static library BUT with the -fpic option, so that the code
> included in the static archive is PIC.
You don't have to; it will work even without -fPIC.
> I browsed through the configuration files of gcc-2.95.2
> and found out that the libstdc++ will only be build in
> PIC, if it is also build as a shared library. (no surprise)
>
> Could this be changed ? Or won't this work anyway...
This does not need to be changed. If you want to build libstdc++ with
additional flags, just put the flags into the Makefile after
configuring, or set CXXFLAGS appropriately.
Regards,
Martin