0

I have a C++ program that uses various C++14 features, and have been asked to compile it for a CentOS 6 system. GCC doesn't support C++14 features on CentOS 6 as far as I can tell (and based on compiler errors).

Is it possible to compile for C++14 on CentOS 6?

Assuming someone has created a whole compatibility layer for compiling C++14 on CentOS6, could I even distribute that executable? Or would the target machine ALSO have to install a compatibility layer?

I recall reading (years ago) about how to use different development toolchains at once, including I think those later than what was supported by the repos for the OS. Just can't recall details.

TSG
  • 4,242
  • 9
  • 61
  • 121
  • What version of gcc do you have installed? Looks like you need at least 5. https://gcc.gnu.org/projects/cxx-status.html#cxx14 – Retired Ninja Jan 03 '22 at 20:56
  • 2
    CentOS 6 has [seen its last maintenance update in November **2020**](https://wiki.centos.org/FAQ/General#What_is_the_support_.27.27end_of_life.27.27_for_each_CentOS_release.3F), i.e. over a year ago. I would have to hear a *very* convincing argument from the person doing the asking why I should bother compiling a binary for a dead OS version. Not just for the reasons stated in this question, but for safety and sanity reasons. – DevSolar Jan 03 '22 at 21:25
  • @DevSolar I deal with this at work. Containers have been a blessing and curse in this regard. Also, that'd be my answer, if CentOS 6 could support containers. I don't think it can even do that. – sweenish Jan 03 '22 at 21:59
  • @RetiredNinja I'm running gcc 4.4.7 (last available from CentOS repo). – TSG Jan 03 '22 at 22:13
  • @DevSolar - My customer is pretty tech savvy so I assume they have carefully thought through their decision to use CentOS 6. (Not all customers appreciate that type of feedback) – TSG Jan 03 '22 at 22:14
  • can't you just install a newer version of gcc? https://stackoverflow.com/a/37355018/2805305 – bolov Jan 03 '22 at 22:37
  • Well, you don't have to appreciate the customer feedback either. There are many very good reasons to update, and very few not to. I'd really rather battle with whatever is holding them back than with a partial update. Bt it's not my battle, so... ;-) – DevSolar Jan 03 '22 at 22:59
  • @bolov - no, the dependent packages are not available for CentOS 6 – TSG Jan 04 '22 at 00:09
  • @TSG some ideas then: build gcc with static linking or use docker – bolov Jan 04 '22 at 00:20

1 Answers1

-1

No, it is not possible to compile C++14 on CentOS 6. Only some C++11 features are available on CentOS 6.

CentOS runs GCC 4.4.7 where-in C++14 features start to become available with GCC 4.9 and higher.

The Boost libraries may be used to replicate some modern C++ features if on an outdated GCC version.

b-john
  • 1
  • 1
  • 1
    It is completely possible to compile gcc 5 on CentOS 6 and get the needed support. I believe there is even a dev repo where you can just `yum install` a newer gcc. However, the real issue is a dead OS being used in a production environment. – sweenish Jan 04 '22 at 15:20