How to use gcc installed in macports?

I installed gcc 4.6. from macports (to support C ++ 0x). But when I check "gcc -version", it shows an older version. How to use the new gcc installed in macports?

+37
c ++ gcc macports macos
Dec 02 '11 at 18:40
source share
3 answers

I remember that this is something like g++-mp-4.6 . I believe that just setting the CXX environment variable is CXX .

+7
Dec 02 '11 at 18:44
source share

You can control the symlink in / /opt/local/bin/gcc using port select . You can view the available version with port select --list gcc . Everything that is specified in the mp- prefix refers to the native MacPorts port, gcc42 and llvm-gcc42 refer to the compilers that come with Apple's Xcode.

An example from my system:

 $ port select --list gcc Available versions for gcc: gcc42 llvm-gcc42 mp-gcc45 none (active) $ sudo port select --set gcc mp-gcc45 Password: Selecting 'mp-gcc45' for 'gcc' succeeded. 'mp-gcc45' is now active. 

After that, open a new terminal window or enter hash -r so that bash recognizes the change.

+89
Dec 04 '11 at 1:12
source share

Just make sure the macports path starts first in your $PATH . Or use gcc-mp-4.6 or something like that.

+2
Dec 02 '11 at 18:43
source share



All Articles