Updating /usr/include/c++ in CentOS-7 - centos7

I have installed the devtoolset-10 package on CentOS 7 and run the /opt/rh/devtoolset-10/enable script so that now when I do this:
g++ --version
I get this:
g++ (GCC) 10.2.1 20210130 (Red Hat 10.2.1-11)
Great. Trouble is, the headers under /usr/include/c++ still point to ye olde libstdc++-4.8.5. That is, if I do ls in /usr/include/c++, all I see is:
bash-4.2$ ls /usr/include/c++
4.8.2 4.8.5
What is the magic incantation to "enable" libstdc++-10 to be the default system C++ stdlib?

devtoolset-10
Every g++ comes with it's own headers. /usr/include/c++/4.8* is for 4.8.5 only.
devtoolset-10: g++ version 10 is using the headers at /opt/rh/devtoolset-10/root/usr/include/c++/10
"enable" libstdc++-10
There is no shared library "libstdc++-10". There is /opt/rh/devtoolset-10/root/usr/lib/gcc/x86_64-redhat-linux/10/{ libstdc++.a, libstdc++.so } , where libstdc++.so is a ~200B text file.

I guess the users are supposed to query gcc for the include path.
On my CentOS /usr/include/c++ is not a symlink, and is not supposed to point anywhere, but one can work around that using update-alternatives (I did that only for the compiler itself only, though). Might be overriden by an update, but those don't happen often enough on CentOS.

What is the magic incantation to "enable" libstdc++-10 to be the default system C++ stdlib?
Developer Toolset uses a hybrid linkage model. This means that it does not come with its own libstdc++.so.6, but uses the system version as far as possible. The missing parts are linked statically. This is achieved by the linker script that Knud Larsen mentions.

If you want to compile using headers from the latest C++ compiler you have on Centos7:
Remove your build directory
Export your chosen compiler specifically: export CXX=g++
Thanks to this comment from github:

Related

How to install gcc 11.2.0 on macOS Big Sur with the Apple M1 processor

How do I install the latest version of GCC on my macOS Big Sur. I am using Visual Studio Code, version 1.60 and I want to run C++ programs using it. I tried using homebrew to install GCC but it kept on giving me errors.
E.g.: When I typed in the path as /opt/homebrew/Cellar/gcc/11.2.0/bin
Result: zsh: permission denied: /opt/homebrew/Cellar/gcc/11.2.0/bin
What is wrong with the permission? How will I make it allow.
Firstly, /opt/homebrew/Cellar/gcc/11.2.0/bin is a directory, so you can't run that.
Secondly, homebrew generally makes symbolic links in /usr/local/bin for everything it installs, so you should add that to your PATH, e.g.
export PATH=/usr/local/bin:$PATH
Then you need to look in /usr/local/bin to see what program name you need, e.g.
ls /usr/local/bin/gcc*
and if you see gcc-11 in there, you then need to compile with:
gcc-11 program.c
Note you will need to look for g++* if you actually mean C++ rather than C.

How to use previous versions of g++

I am currently running a debian Jessy whose g++'s version is 4.9. For some reason I need to compile a code in g++-4.7 or previous version.
I got the files of gcc-4.7 and g++-4.7 from a debian wheezy of a friend who has g++-4.7.
I tried to make the apt-get install, it seemed to have worked for the gcc but not for the g++. I put the files in the /bin, but he doesn't seem to locate the g++-4.7 package.
When I try to compile my code I specify g++-4.7 but get the error :
g++: error trying to exec 'cc1plus': execvp: No such file or directory
Any idea how to figure this out?
My advise is to add the wheezy repositories to /etc/apt/sources.list and then install g++-4.7 using apt-get. Using this method you will also get bugfixes etc.
I guess, currently you're just having dependency Problems. These will be solved when you use apt-get.
It is very easy to install gcc from sources. Remember that you have also to use a binutils version which maps to the gcc version. Mostly it is possible to run older gcc versions on actual binutils, but I have also seen a problem during install.
I have installed a long list of gcc versions in /opt/
Simply copy an older gcc version somewhere in the file system can result in problems with using the correct library versions.
If you install different gcc versions and also the related libraries e.g.libstdc++ , don't forget to update your library data base ( ldconfig/LD_LIBRARY_PATH/...) Maybe http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html can help.

I installed GCC 5.2 from source and I don't know how to uninstall it on Ubuntu 15.04

The other week I installed GCC 5.2 from source on my ubuntu machine. I wanted to be able to use fully supported cilk features. Now I would like to revert back to GCC 4.9. How can I uninstall GCC 5.2? I tried using make uninstall but as I understand this is not supported.
I believe you don't need to revert to the system compiler; it is a matter of path. Or set up your $PATH appropriately. Use /usr/bin/g++ for the system compiler, and probably /usr/local/bin/g++ for the compiler you have built from source code from GCC
BTW, you probably could use your GCC 5.2 for almost all your future builds
It depends how you have configured it. You should have configured it with ../gcc-5.2/configure --program-suffix=-my-5.2 then you would use g++-my-5.2 instead of g++
Try to type g++ -v (i.e. probably /usr/local/bin/g++ -v) to understand how it was configured.
You probably could remove the gcc and g++ binaries under /usr/local/bin/ and several other files and directories under /usr/local/ (but be careful).
Indeed, GCC does not support make uninstall

ICC (14.0) cannot even compile hello-world in Ubuntu 13.10?

New to Linux, I just installed a Ubuntu 13.10 64 bit, with Eclipse 3.8 and intel's ICC 14.0.
The GCC come with Ubuntu is version 4.8.1.
So far ICC installed cannot even compile hello-world in Eclipse due to it cannot compile iostream header.
The iostream header will include another header, called c++config.h, stored in /usr/include/x86_64-linux-gnu/c++/4.8/bits
The iostream header itself stored in /usr/include/c++/4.8
The GCC compiler can compile the hello-world cpp and other c++ files perfectly, yet the ICC cannot even compile hello-world, tell me it cannot find c++config.h header, even if I include its path in the project.
Anyone know any work-around for this?
You can:
Add system include on command line
icc -idirafter /usr/include/x86_64-linux-gnu/c++/4.8/ -I... -L... my.cpp
Permanently add it to icc.cfg
cat /opt/intel/composer_xe_2013_sp1.1.106/bin/intel64/icc.cfg
-idirafter /usr/include/x86_64-linux-gnu/c++/4.8/
I successfully used this to compile scipy.
Two possibilities exist without changing too much of your setup:
Install an older version of GCC alongside the default one, assuming that ICC will work with some version, just maybe not the very new one you have now.
Install a newer version of ICC. It looks like you may already have the latest, but perhaps there is a patch release. I somewhat doubt it though.
This kind of thing happens fairly often when mixing and matching different compilers and standard libraries. It helps if both are of roughly the same age.

Know g++ Version of Code blocks in Windows

I am solving questions on Interviewstreet.com. They said they use C++ version g++ 4.6.3,C0x mode.
I am writing code on code blocks. So i want to know which version iam using in code blocks is it in C0x mode or C11 mode??
I have tried using g++ --version i got g++ TDM-2 mingw32 4.4.1.Can u tell me where i can get this kind of information.
what is the difference between C++ 0x and C++11??
You'll have to update the version of g++ to 4.6.3 (or later) if you want to use c++11 features. See this question and it's answers on how to do it for deb linux.
Then you'll have to pass --std=c++0x to the compiler in options. You should be able to easily find them in codeblocks.
what is the difference between C++ 0x and C++11??
c++0x is a synonym for c++11.
The command:
g++ --version
gives you the version of your g++ or mingw compiler. Since you got g++ TDM-2 mingw32 4.4.1 then your version is 4.4.1. If you want to use version 4.6.3 as in that web site, then you would have to update.
It wouldn't hurt to use a newer than 4.6.3 version of mingw, so please see here for the latest version. This page offers an windows installer for mingw.
After installation, you would have to configure CodeBlocks to use the newly installed compiler by looking into Compiler and debugger settings -> Toolchain executables tab and setting the paths for the compiler-related executables to the new ones.
Hope this helps.
EDIT:
Here is a small tutorial/example of what the CodeBlocks settings look like.