5

I'm trying to compile a C++11 project on a bunch of old machines with old kernels. They're running CentOS 6.2, 6.3 Alt Linux 4.1. Others are unknown but similarly old. The machines won't let me install a newer version of GCC. 4.4 is the max they can run, and rewriting the project isn't an option.

I somehow managed to build GCC 4.6 locally on one machine, and used it to compile my project, but I don't want to repeat that on every machine. Is there a painless way to compile or run the code on all the machines?

tshepang
  • 65,642
  • Working, but bad solution: Compile the binary static. Then it should run under the other machines without having to install newer gcc runtime libraries there. – jofel Oct 08 '13 at 14:17
  • @jofel, is it possible to link all required staff in the application? solutions from quick googling did not make a magic for me, but if it is possible - i will focus on that direction – user286215 Oct 08 '13 at 14:26
  • I suggesst downgrade your OS.find a old distro. – PersianGulf Oct 08 '13 at 14:30
  • @jofel It's not that easy. Even a static binary is not guaranteed to run on a different machine, there are more factors involved. It might work sometimes, though. – Marco Oct 08 '13 at 14:36
  • 3
    @MohsenPahlevanzadeh How does downgrading solve the problem? Old distros do not have C++11 support and newer ones do not ship with the required drivers. (From my own experience I can confirm that this is indeed an issue.) – Marco Oct 08 '13 at 14:38
  • doesn your program wwork with gcc3.x ? – PersianGulf Oct 08 '13 at 14:41
  • FYI: glibc does not fully support static compilation. At minimum, expect anything involving name-service switch (NSS; /etc/nsswitch.conf) to break. – derobert Oct 08 '13 at 15:11
  • 1
    @user286215 “Is there a painless way to compile or run the code on all the machines?” I'm afraid, the answer is no. You may want to add some information to your question why upgrading to a newer distribution (the obvious solution) is not an option. – Marco Oct 08 '13 at 15:17
  • Is it possible to upgrade these old machines to something more modern? – bigdaveyl Oct 08 '13 at 14:23
  • @bigdaveyl no ( they have some specific hardware and drivers are only available for old kernels.. and so on ) – user286215 Oct 08 '13 at 14:24
  • @Marco, few reasons here: Machines are complex HPC clusters with many nodes and many manually installed packets. System administrators do not want to mess with upgrades, interrupting a normal cluster work for weeks. Some Infiniband drivers work only with old kernels and forcing a new driver to work is a big problem also.

    So it just an environment - i should not have aimed for c++11, but did not expect such problem )

    – user286215 Oct 08 '13 at 21:15
  • @user286215 how about compiling the compiler statically? Then you can deploy it on "almost" anything and use that for compiling "natively". – peterph Oct 09 '13 at 08:19
  • It's rather surprising that Microsoft supports C++14 for Windows XP from 2001 (MSVC2015 still has XP redistributable) but CentOS 6.3 (2012) doesn't support C++11. 14 years of backwards support versus lack of support for current standards. Sure, in theoretical sense todays GCC supports C++14 better, but the executables it builds just won't run anywhere. – MSalters Jan 11 '16 at 13:41

2 Answers2

2

Probably the best way would be to compile the new version of gcc for all of the machines. You can do this with a script (lfs does this). You should be "safe" copying, pasting, and then running the script from a temp account via ssh.

You could also try and update your repos to have Centos install them for you. Centos might try to upgrade your entire system though.

Also, are you using -std=c++11? If so, you might want to try -std=c++0x.

SailorCire
  • 2,503
1

The problem is still actual for me and i've found a nice solution for CentOS - Devtoolset https://www.softwarecollections.org/en/scls/rhscl/devtoolset-3/

It provides a current versions of GCC and some other tools for RHEL/CentOS 6/7.