This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: C++ binary compatibility between different versions of gcc


On 5 March 2013 12:27, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> On 5 March 2013 10:39,  <Heiko.Papenfuss@uniserv.com> wrote:
> > Does this mean that it would be possible to link with any GCC that
> > supports -fabi-version=2 against any libstdc++.so.6.x.y?
> 
> I'm not sure I understand what you're asking.
> 
> GCC doesn't do linking, it just forwards arguments to the linker. The
> -fabi-version option is not used at link-time, that only affects
> code-generation at compile-time.  So in theory you can use *any* gcc
> driver to link compatible objects together if you explicitly say which
> libstdc++.so to use, because the list of objects and libraries will be
> forwarded to the linker, but just using the g++ driver that matches
> that libstdc++.so is by far the simplest approach.
> 
> Also, you can't link against *any* libstdc++.so.6.x.y, you must link
> against a version that is no older than required by any of your
> objects.  If your program consists of three objects and you compile
> foo.o and bar.o with GCC 4.1.2 and baz.o with GCC 4.6.3 then you must
> link your program to libstdc++.6.0.16 or later, because baz.o will
> depend on the GLIBCXX_3.4.16 version that is only found in
> libstdc++.so.6.0.16 and later.
> 
> If that doesn't answer your question please be more specific,
> providing a concrete example with commands showing what you're asking
> about.

Despite my unclear wording that is what I wanted to know.

> > Another question comes to my mind here: Let's assume I have two object files
> > or libraries that have been compiled separately and were compiled with
> > different versions of GCC thus needing different versions of libstdc++.so
> > at run-time. Do I read [2], "Multiple ABI Testing", correctly that I should
> > be able to compile and run a program which uses both libraries provided that
> > the most current libstdc++.so that any library depends on is present at
> > run-time?
> 
> The "Multiple ABI Testing" docs refer to using incompatible libraries,
> e.g. libstdc++.so.5 and libstdc++.so.6, in the same process. It's hard
> to get right, can only be done if no library types (or type_info or
> exceptions or polymorphic types) cross library boundaries, and I'm not
> sure those docs are 100% accurate.  If you just want to link objects
> compiled with GCC 4.X with objects compiled with GCC 4.Y then that
> section of the docs is not relevant.
> 

Thanks for clarifying that for me!

Heiko


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]