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?
Related
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.
This is really annoying. For some reason, on MacOS X 10.11 (probably also on previous versions) there are gcc and g++ commands (in /usr/bin, they are not aliases or so) which, when executed with the -v argument, give:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.2.0
Thread model: posix
So it looks like they actually execute the clang and clang++ compilers by apple. Now, I really need my computer to execute gcc and g++ when I invoke those commands, both from the terminal and through makefiles.
The reasons for this are two:
I like to have my computer do what I ask it to do.
Apparently clang++ compiles stuff using a different c++ standard library from g++, and this is causing me problems when I compile and link my stuff with g++-5 (the ACTUAL g++, installed via homebrew) against CppUnit.
Does anybody know what is the best way to have gcc and g++ actually call gcc and g++?
Include in your PATH, before /usr/bin, a directory that contains a symbolic link named gcc pointing to /…/bin/gcc-5.
The latest Mac OS X does not let you change /usr, from what I hear, so this conservative solution is the only one available.
when I invoke those commands, both from the terminal and through makefiles.
If you adjust your PATH variable in your .profile, both these cases will be covered.
Apple does not actually provide gcc or g++, although (perhaps only misguided) they make aliases to pretend that clang is the same.
You can install gcc and g++ with MacPorts (also with homebrew). I use MacPorts, which puts its executables in /opt/local/bin.
With MacPorts, I see these currently-available ports (programs that have to be compiled to work on one's machine), using this command
port list |grep gcc
gcc410 #5-20140817 lang/gcc410
gcc43 #4.3.6 lang/gcc43
gcc44 #4.4.7 lang/gcc44
gcc45 #4.5.4 lang/gcc45
gcc46 #4.6.4 lang/gcc46
gcc47 #4.7.4 lang/gcc47
gcc48 #4.8.5 lang/gcc48
gcc49 #4.9.3 lang/gcc49
gcc5 #5.2.0 lang/gcc5
gcc6 #6-20151129 lang/gcc6
gccxml-devel #20150423 lang/gccxml-devel
gcc_select #0.1 sysutils/gcc_select
gccmakedep #1.0.3 x11/gccmakedep
According to its webpage, brew would do something similar, but install into /usr/local/bin.
When I installed MacPorts, its installer updated my ~/.profile, adding this to update PATH:
# MacPorts Installer addition on 2015-10-03_at_14:17:30: adding an appropriate PATH variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.
Each of those ports from MacPorts installs gcc with a different name, and the port script has a feature select which establishes a symbolic link, e.g., from gcc to gcc49. brew has something similar. According to How can I brew link a specific version?, you would use
brew switch gcc-package-name package-version
e.g., (guessing at a valid name)
brew switch gcc 4.9
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.
I think I have several versions of gcc installed on my Mac OSX.
Right now, when I type gcc --version. I got gcc (GCC) 4.6.0 20100703 (experimental)
.
But I want to use earlier version gcc.
The thing is, i don't know how to find the path of older version gcc.
Can anyone help me?
Thanks.
By default, your gcc installations should be in /usr/bin/. So, for example, to use gcc 4.2, you'd use /usr/bin/gcc-4.2 to compile your files. You can do ls /usr/bin/gcc* to see which ones you have installed.
EDIT:
If gcc isn't installed in the default path (i.e., /usr/bin/), then you can execute locate gcc in the terminal to find where it is located.
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.