1

For some reason, I have some object files compiled with GCC 5.4.x and some object files compiled with GCC 6.x . The source code is C++14 and I'm on a x86_64 machine running GNU/Linux 4.4.x.

Is it ever, at all, possible to link my objects together? If so, what are the restrictions/conditions for it to be possible, or what procedure do I need to follow to make it possible?

einpoklum
  • 118,144
  • 57
  • 340
  • 684
  • You don't need to do anything, it works and is a supported use case. – Jonathan Wakely Mar 04 '17 at 21:15
  • Possibly related: http://stackoverflow.com/q/10717106 – Kerrek SB Mar 04 '17 at 21:18
  • You need to link them together. If you don't get any unresolved symbols, then it works. I believe these two particular versions are compatible. You need to use the standard library from the 6.x version. – n. m. could be an AI Mar 04 '17 at 21:45
  • @n.m.: Do you mean I need to compile the 5.4.x C++ sources with the 6.x standard library headers, or just use the 6.x standard library for linking? – einpoklum Mar 04 '17 at 22:02
  • 1
    The latter. There's nothing to compile, you are only linking. – n. m. could be an AI Mar 04 '17 at 22:31
  • @JonathanWakely: Really? No restrictions at all? Different flags? It will "just work?? ... If so, please make it an answer :-) – einpoklum Mar 04 '17 at 23:25
  • If you use flags that change ABI (such as `-fshort-enums`) then it won't work, but that's true even if you compile all objects with the same compiler version and use ABI-changing flags for some objects and not others. G++ 6 is backwards compatible with GCC 5. At run-time you need to use the `libstdc++.so` from the newest compiler version used for any of the objects in the link. – Jonathan Wakely Mar 04 '17 at 23:37

0 Answers0