Set default GCC to Fink-installed GCC 4.5? - gcc

I've got GCC 4.2 that came with my installation of Mac OS X 10.6.4, plus GCC 4.5 installed via Fink. I wanted to use gcc_select to change the default compiler to GCC 4.5, but was told gcc_select does not exist.
Is there another way to set the default compiler? Or do I need to do so manually? If so, how?
Thanks!!

I used MacPorts to install my GCC 4.4, and also told MacPorts to download gcc_select:
sudo port install gcc_select
then I typed
gcc_select -l
to list the available versions. Then
gcc_select mp-gcc44
to switch. I haven't used Fink but hopefully you can install gcc_select from there :)

Related

Run or use GCC without install

Can I use GCC for e.g GCC4.0.3 without installation
In my macOS I have installed Clang xcode , and GCC from Homebrew
In my Linux they are installed as well
But I want to use GCC (Specially older version) besides most updated version
Like NVM that manage Node version and it lets you install many nodejs with different version on your system
I want to use GCC4 specially for science and compiling Old FORTRAN to make my Source codes run and see the results
In new OS both macOS and Linux when you install gcc it will install most updated and that is not useful for old fortran or old codes.
So In my solution i think its better to use gcc without install or even install gcc to custom directory folder and copy the codes in that directory and compile them but not to install as wide system and make incompatibility with default GCC and CLANG on system
Thanks in advance

How to install the latest version of GCC on Mac OS?

I've tried googling but it all just confuses me.
Does anyone know how to do this?
Using homebrew you can install version 7.2.0 of gcc pretty easily.
Follow the installation instructions on https://brew.sh/. After installing, run the following command in your terminal (Terminal.app):
brew install gcc
That will install version 7.2.0 using the current gcc forumla which appears to currently be the latest version.

Install GCC 5.X on Xcode 6

I need to use/integrate GCC 5.X (in my case 5.3, and it is already installed) on Xcode 6.2.
I've found a lot of outdated tutorials about GCC 4.X and Xcode 5 (or lower), but all of them are outdated and do not work anymore.
I've also found this tutorial, but I have not the 5.3.xcplugin file that the tuto recommend to copy.
I am still on Mac OS X Maverick, and I can install Xcode 7 if necessary.
Anybody would know how to do it?
MacPorts still has an installer for Mavericks. It will likely add /opt/local/bin:/opt/local/sbin to your $PATH in .profile, or whatever shell startup file you use, and leave a backup of the old file you can probably get rid of once you're satisfied.
I would suggest upgrading to the latest Xcode release - and to El Capitan unless you have some specific reason not to. AFAIK, if you can run Mavericks, you can run the latter. I will avoid any arguments about the merits of Brew vs. MacPorts here. There's plenty of documentation on the MacPorts pages.
Make sure the package database is up to date:
sudo port -v selfupdate`
Have a look at the existing gcc ports:
port list | grep gcc
note: you might as well install the stable gcc6 (6.1.0) package.
Install the package - this may also install dependency packages:
sudo port install gcc6 [-universal]
This may take a while, as it might need to build from source. For most packages, the -universal flag says that you don't care about 32-bit (IA32) builds, etc.
You can see various package versions with port select ... options, e.g.,
port select --list gcc
And enable the installed gcc:
sudo port select --set gcc mp-gcc6
You may need to rehash so the shell adds the new binaries to its search. Or just start a new shell. gcc -v should yield something like:
gcc version 6.1.0 (MacPorts gcc6 6.1.0_0)

C++11 headers missing on Mac OS X 10.8.2 (MountainLion)

I'm new to Mac. I have some Linux and Windows C++11 source which uses Boost I'd like to build on this Mac. Installed MacPort (should I instead be using Homebrew?) then successfully ran commands such as:
sudo port install cmake
sudo port install boost
sudo port install openssl
sudo port install gcc49
sudo port install gcc_select
sudo port install --set gcc mp-gcc49
CMake correctly finds Boost 1.57.0 and sets up the makefile. But when I run make, it seems it cannot find normal C++11 headers such as "chrono":
In file included from ../src/test.cpp:10:
../src/test_private.hpp:33:10: fatal error: 'chrono' file not found
#include <chrono>
^
1 error generated.
Indeed, when I go looking for the C++ header files, I see some of them in /usr/include/c++/4.2.1/ but newer files such as chrono and thread are missing.
Is there another package I need to install before I can compile C++11 source code on a Mac?
Xcode, the Apple supplied compiler/tools, comes with two implementations of the std::lib:
gcc's libstdc++, version 4.2.
libc++
The first is very, very old, and does not support anything in C++11 such as <chrono>. The second supports C++11 quite well, but can only be used with clang, not gcc. clang comes with Xcode.
You will also need to install command line tools after you install Xcode:
xcode-select --install

Gcc 4.2 version missing

on my new macbook pro with osx lion and XCode 4.1 I have some problems with gcc.
In /usr/bin I cannot find gcc-4.2
I only have the following versions:
i686-apple-darwin11-llvm-gcc-4.2
llvm-gcc
llvm-gcc-4.2
As a result when I try to select gcc42 by means of port select --set gcc gcc42 it returns me the following error:
Selecting 'gcc42' for 'gcc' failed: could not create new link "/opt/local/bin/gcc": target "/usr/bin/gcc-4.2" doesn't exist
However port select gcc returns me the following versions:
apple-gcc42
gcc42
llvm-gcc42 (active)
mp-gcc44
How can I fix this problem?
Thanks!
I could manage to solve this issue in Mountain Lion with a symbolic link:
sudo ln -s /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2
Hope this help someone
There should be a /usr/bin/gcc-4.2 with Xcode 4.1 installed. However, with the recent Xcode 4.2 update, Apple has finally removed their modified standard gcc-4.2. What remains is either llvm-gcc42 (also symlinked to gcc) and clang, the newer non-gcc C compiler. Apple is making the transition to clang; the first step is using the hybrid llvm-gcc42. There have been some reported problems using either of the new compilers. You should be using this time to figure out if you have problems with them and, if so, fix your code and report bugs to Apple. In the meantime, if you absolutely have to have the old gcc-4.2, it is possible to build one similar to the previous Apple-modified one via MacPorts:
port install apple-gcc42
but you'll be swimming against the tide.
With Xcode 4.3, you need to install the Command Line Tools separately. XCode -> Preferences -> Downloads, Click the Components button, and then click Install next to the "Command Line Tools" option.
I had the same issue.
I fixed it by doing a symlink.
Like this :
cd /usr/bin
then :
sudo ln -s llvm-gcc-4.2 gcc-4.2
You might consider compiling a newer GCC (e.g. 4.6.2) from its source code. Apple does not care much any more about GCC, but GCC has made significant progress since 4.2
And you probably could use your llvm-gcc42 as a GCC compiler.
I tampered with the innards of the makefile and found out that one invoked option provided an argument too many; replaced the variable with the actual result of the function called on my machine (removing the excess argument) and did run make again it worked.

Resources