This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: -fPIC and static libstdc++
- From: Ian Lance Taylor <iant at google dot com>
- To: Philip Bennefall <philip at blastbay dot com>
- Cc: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Date: Fri, 18 Oct 2013 11:01:28 -0700
- Subject: Re: -fPIC and static libstdc++
- Authentication-results: sourceware.org; auth=none
- References: <839BCFEEFECB4BF786328EEBFB05CF16 at chicken>
On Fri, Oct 18, 2013 at 8:57 AM, Philip Bennefall <philip@blastbay.com> wrote:
>
> I am building a shared library which will be distributed to clients in
> binary form only. I am attempting to make the same binary run on as many
> Linux variants as possible, and so when I build it I specify the options
> -shared and -fPIC. As part of the effort of making the library as
> independent as possible, I also link both the C and C++ standard libraries
> statically into the final shared library. I want to do this because I use
> C++11 features internally, and I don't want to force the users of my library
> to have a C++11 compiler handy.
>
> When doing this, do I need to build libstdc++ and libgcc from source with
> -fPIC as well? Or is it okay to link with the static versions of these
> libraries that are provided in my Ubuntu 13.04 gcc package?
On GNU/Linux the static versions of libstdc++ and libgcc are normally
compiled with -fPIC, precisely to support the kind of thing you are
doing. So it should work fine.
Ian