-2

Following, my previous question about How to safely deploy an application built with an upgraded compiler, there is still a doubt for me about the C++11 features compatibility. Using devtoolset-2, the application that will be built with gcc 4.8.2 but linked with libstdc++.so.6.0.13 will have full C++11 features supported or only the common set with libstdc++6.0.19 ?

I am not really sure to understand this point actually.

Community
  • 1
  • 1
Fryz
  • 2,119
  • 2
  • 25
  • 45
  • Forget about C++11. You can only expect that C++ code compiled by a given compiler can only be linked with that compiler's corresponding library. It is not guaranteed that you can compile your code with a given version of the compiler, link it with the library from an older version, and expect anything to work. – Sam Varshavchik Jan 06 '17 at 17:48
  • Ok so how to use the devtoolset-2 then ? It become useless in this case. – Fryz Jan 06 '17 at 17:56

1 Answers1

2

You shouldn't be mixing libstdc++ like that, so it's a moot point. You should redistribute the libstdc++ that comes with devtoolset-2 and link against that specifically. Otherwise the compiler and standard library will be at odds with each other, and even they won't know the answer to your question!

Then, simply look up a list of what C++11 features are supported in GCC 4.8.2.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
  • Actually, i understand that there is no mixing between libstdc++ using devtoolset-2 that is provided by RedHat ( but i am using the centos version ) to upgrade the compiler and still using the system libstdc++. So the app is built and run with the same version of libstdc++ (6.0.13). GCC 4.8 is supposed to be backward compatible with libstdc++ 6.0.13 but i ask about the C++11 features support. – Fryz Jan 06 '17 at 17:48
  • @Scab: I don't see how libstdc++ can be unconditionally backwards-compatible. Where would `std::thread` support come from? Move semantics in containers? All the other C++11 features that live in the standard library? Maybe the GCC devs have managed to make it so that a newer compiler can always use an older standard library implementation, but then I guess the answer is "you just don't know what you're going to get". Hence I'd avoid it. – Lightness Races in Orbit Jan 06 '17 at 17:53
  • According to this https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html , i understand that some versions of GCC are compatible with older libdstc++ version, especially if there is only a change in the minor number version ( like 6.0.13 and 6.0.19 ). If there is any doubt about that, then why Red Hat has released their devtoolset collections ? So if i need C++11 full support on centos 6.7 what can i do ? Use gcc 4.8.3 and it's libstdc++ 6.0.19 version ? and so deploy also all the dependancies with the right versions of libc, libgcc_s when deploying the app on centos 6.7 ? – Fryz Jan 06 '17 at 18:06
  • 1
    @Scab: Again I'm no expert so take this with a pinch of salt, but that's what I do (except for libc) and it means I know for sure I have all of C++11 out of the box. I'm hopeful that our customers will migrate from el6 within a few release cycles anyway so I haven't given it much more thought tbh. – Lightness Races in Orbit Jan 06 '17 at 18:12