0

My CentOS 7 machine has a default GCC version of 4.8.5. I want to use a higher version of GCC. So, I executed the following steps in a terminal:

sudo yum install centos-release-scl
sudo yum install devtoolset-10-gcc*
scl enable devtoolset-10 bash

After performing the steps, my GCC is now 10.2.1. I then launched Eclipse CDT (10.2.0) through the terminal. Upon enabling C++20 in Eclipse, I tried to compile a simple "hello world" code, but I received the following error in the Eclipse console:

g++ -std=c++2a -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/dummy2.d" -MT"src/dummy2.o" -o "src/dummy2.o" "../src/dummy2.cpp"
g++: error: unrecognized command line option ‘-std=c++2a’
make: *** [src/dummy2.o] Error 1
"make all" terminated with exit code 2. Build might be incomplete.

My system PATH variable has the following directory as its first entry: /opt/rh/devtoolset-10/root/usr/bin. So, I don't know why my Eclipse is still using the old GCC 4.8.5. How do I adjust my Eclipse settings so that I am able to compile higher versions of C++ in CentOS 7?

hermit.crab
  • 852
  • 1
  • 8
  • 20
  • The [answer](https://www.eclipse.org/forums/index.php/t/245708/) is most likely one google search away. – super Jun 20 '21 at 06:56
  • I think the devtoolset g++ is using the old libstdc++ version 4.8.5 . That's the reason for these https://stackoverflow.com/questions/47175706/how-to-install-gcc-4-9-2-on-rhel-7-4/47189915#47189915 ..... where the latest version so far is 8.4.0`. – Knud Larsen Jun 21 '21 at 12:25
  • 1
    Using devtoolset-10 : `$ scl enable devtoolset-10 bash` ........ then your gcc, g++ are version 10. – Knud Larsen Jun 21 '21 at 12:30
  • @KnudLarsen, I was able to fix the problem by choosing "Linux GCC" instead of "Cross GCC" as the toolchain when creating a new project. Thank you for your comment. – hermit.crab Jun 22 '21 at 00:46
  • Use "sudo yum install devtoolset-10" instead of "sudo yum install devtoolset-10-gcc*" – Ashish Shirodkar Jul 25 '23 at 09:06

1 Answers1

1

I used following steps on CentOS-7 and they worked fine for me:

yum install centos-release-scl
yum install devtoolset-10
scl enable devtoolset-10 bash

I used same flags which you used:

g++ -std=c++2a -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/dummy2.d" -MT"src/dummy2.o" -o "src/dummy2.o" "../src/dummy2.cpp"