0

I am struggling to build a climate model that depends heavily on C and Fortran compilers installed on the machine.

I installed XCode and its default compilers, but I had to install more recent versions from MacPorts since I need updated compilers.

Therefore, I currently have two distinct versions of the compilers installed on my Mac (using here gcc as an example, but it is the same with gfortran):

gcc, from XCode, installed on /usr/local/bin/gfortran

gcc-mp-4.9, from MacPorts, installed on /opt/local/bin/gcc-mp-4.9

What I need to do is to set gcc-mp-4.9 as the default gcc compiler of the system, for any purpose at all. I created an alias on my bash.profile:

alias gcc='gcc-mp-4.9'

which works if I just type gcc on terminal. However, if I type "which gcc", the system still detects the old version:

$ which gcc 
/usr/bin/gcc

which causes me some troubles, because most of the libraries I have to build rely on the output of 'which' to determine the compiler to be used.

Without removing /usr/bin/gcc or creating symblic links, is there any way to indicate to the system that gcc-mp-4.9 is the default gcc compiler for any occasion?

Thanks in advance, Thiago.

1

After some deeper research, I came up with the solution. I solved this problem by using MacPorts:

sudo port select --set gcc mp-gcc49

So, problem solved!

  • It may not be useful with this issue, but I've also used soft links to force particular versions of software to be used. e.g. /usr/local/bin/gcc is a soft link to the desired gcc version. – Scot Jan 1 '15 at 1:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .