I installed the devtoolset-4 software collection on a CentOS 7 machine that I'm using for development. This software collection includes the compiler I want to use, g++ 5.2.1, as well as Eclipse CDT 4.5 (Mars). When I create a new c++ project in Eclipse and navigate to the project properties (right click on project, then Properties -> C/C++ Build -> Environment) I can see that Eclipse has created a PATH environment variable that gets appended to the current PATH when building my project. The value of the Eclipse-defined PATH is:
/bin:/opt/rh/devtoolset-4/root/usr/bin:/opt/rh/rh-java-common/root/usr/bin:/usr/lib64/qt-3.3/bin:/home/kts/perl5/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/sbin:/home/kts/.local/bin:/home/kts/bin
The first entry in the PATH is /bin, which on CentOS 7 is a symlink to /usr/bin. In /usr/bin is the g++ 4.8.5 binary that gets installed from the official CentOS repositories. This results in Eclipse building my project with g++ 4.8.5 instead of the version I actually want it to use, which is the g++ 5.2.1 binary sitting in the /opt/rh/devtoolset-4/root/usr/bin directory (second entry in PATH). If I remove the /bin entry from the Eclipse PATH variable my project then builds with the desired g++ 5.2.1.
I'm a little hesitant to rely on this fix moving forward though, as I expected that projects created in the version of Eclipse that is included in devtoolset-4 would work out of the box with the version of g++ included in devtoolset-4. Has anyone else run into this problem? Is there something I'm not doing correctly in my use of the devtoolset-4 software collection? Or is this a bug? Any insight is greatly appreciated.