Installing latest version of GCC from source - c++

i want to install latest version of GCC on RHEL 6.5 version.There is a old version of GCC already installed(GCC version 4.4.7 20120313).I want a way such that i need to install GCC in my private folder and only i can use this to compile code.other users who compile should be based on older version.

Related

How to change the gcc version on the Mac

Recently, I want to use a database which need gcc/g++ +4.3 in the Mac. the default gcc version is 4.2.1, like this:
So I use the brew to install the latest gcc 5.3:
But how to change the gcc version to the 5.3?

Difference between installed packages of GCC compiler

After I installed the gcc cross compiler on my ubuntu, I noticed a few new packages.
arm-linux-gnueabihf-g++
arm-linux-gnueabihf-g++-4.8
Both packages compile my code correctly. I suspect that one compiler is a version independent (ie once i install version 4.9 this package would still be named as it is) and one is specifically for version 4.8 only.
What could be the difference between the following two packages and which one I should use to cross compile in eclipse?

How to install GCC 5.1 on Linux (Ubuntu)

I'd like to experiment with the new GCC 5.1 C++ compiler on Ubuntu.
How can I install GCC 5.1 on Ubuntu?
I'd prefer some form of pre-built executable that I could just download and install, instead of downloading GCC's sources and building the whole GCC 5.1 from them.
Moreover, since I read libstdc++'s ABI changed in GCC 5, must a new version of libstdc++ be installed with GCC 5.1, too?
Package g++-5 (gcc version 5.2.1) is available in debian testing or in ubuntu wily. Previous milestones are 4.9 and 4.8. It would be more difficult to get a version in between, like 5.1.
If still satisfied with 5.2.1 then add this line to /etc/apt/sources.list:
deb http://ftp.debian.org/debian/ stretch main
Try to install package and its dependencies:
# apt-get update
# apt-get install g++-5
Then hope it is going to be installed without problems.
(It strongly depends which ubuntu version is used on host.)
A g++-4.9 install from stable debian (jessie) to ubuntu trusty (gcc 4.8) has been successful for me. When done comment out previously added line from sources list and
# apt-get update
If you are fond of eternal upgrades then set an apt pinning rule instead.

gcc version showing 4.2.1 even after installing 4.9 (Homebrew)

I installed gcc version 4.9 with homebrew in my mac. But when I check the gcc version in terminal it is showing still the old one.
Aarons-MacBook-Air:bin Aaron$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.1.0
Thread model: posix
Please help
homebrew installs gcc with version specific suffixes, so when you install gcc49, it gets called gcc-4.9 on the command line. This is intended to prevent interference with the gcc stub (which is actually clang) which is provided by the OSX command line development toolchain, as well as to allow you to install gcc-4.8, gcc-4.7, etc. alongside each other.
Generally defining the environment variables CC=gcc-4.9 and CXX=g++-4.9 should allow you to compile autoconf based packages, as well as standard makefile based projects using the gcc-4.9 compiler, rather than using the default cc/gcc.

Updating Apple g++/gcc

What is the difference between Apple gcc and GNU gcc? Is Apple gcc a superset of the standard one?
The g++ version information in my OSX shows:
$ g++ --version
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
Some of the latest features of C++11 are in gcc 4.3/4.4 as per this. Is there any newer version of Apple gcc I can upgrade to. if so, how can i do it? I have Xcode 4.1
Well, for the first part, Apple in this case is using the LLVM backend for g++ as the default g++. Apple also installs the wonderfully named clang and clang++ front-ends for LLVM. However, there is absolutely nothing stopping you from installing newer branches of GCC; MacPorts has packages for everything up to 4.6. If you look for "APPLE ONLY" in the gcc man page, you can see what won't be available outside of Apple branches.
Beside the already mentioned llvm-gcc and clang, there is also an Apple-supplied gcc-4.2 (without LLVM backend) at /usr/bin/gcc-4.2 in Xcode 4.1. But do not overwrite the Apple-supplied versions in /usr/bin. All three support a superset of features include multi-arch support and multi-abi support not found in the vanilla GNU distributions and many third-party packages depend on these features in OS X. If you install something via MacPorts or from source, it will be installed to a different path, like /opt/local/bin or /usr/local/bin. Use PATHs or environment variables to manage which compiler you use.
You can use macport to install newer versions. You can download it here. Once you have installed gcc with macport, you can use it with xcode by adding an user-defined setting to your build :
- Go to the build setting of your project
- Click on the add build setting button
- Choose user-defined setting
- Name it CC
- In the value field, put the path of the gcc version installed by macport.
One thing that definitely is present in the Apple GCC branch but not in GNU GCC is blocks.