macports - Change GCC version on Mac OSX Lion

06
2014-04
  • Donny P

    I'm currently running GCC 4.2. I would like to switch to a more recent version.

    I have Homebrew and I have MacPorts for package management. I've followed several tutorials today for installing a newer version of GCC, but everytime I get finished and type gcc -v and I still get that I'm using 4.2. How can I switch this? If you need more info let me know, I'm pretty new to system packages.

  • Answers
  • phe0113

    Just a quick question: do you properly set the PATH environment variable, i.e. put the path of newer version of GCC (you just installed) before the path of GCC 4.2 (maybe the system default), so that when your operating system looks for needed executable, it will find the newer version first?

  • eiennohito

    As far as I know, Homebrew installs gcc with version suffix. For example I have gcc 4.8 installed and it is available as gcc-4.8. Try to check if you have the same pattern of files.


  • Related Question

    macports - configure architecture?
  • crippledlambda

    When trying to install a more recent version of subversion, I get an installation error for 'apr'. When I look at the log file, it says:

    :debug:main Using compiler 'Mac OS X gcc 4.0'
    :debug:configure Environment: CPATH='/opt/local/include' CFLAGS='-O2 -arch i386' CPPFLAGS='-I/opt/local/include' CXXFLAGS='-O2 -arch i386' LIBRARY_PATH='/opt/local/lib' MACOSX_DEPLOYMENT_TARGET='10.5' ac_cv_path_SED='sed' CXX='/usr/bin/g++-4.0' CC_PRINT_OPTIONS_FILE='/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_apr/work/.CC_PRINT_OPTIONS' F90FLAGS='-O2 -m32' LDFLAGS='-L/opt/local/lib -arch i386' FCFLAGS='-O2 -m32' lt_ECHO='/bin/echo' OBJC='/usr/bin/gcc-4.0' INSTALL='/usr/bin/install -c' FFLAGS='-O2 -m32' OBJCFLAGS='-O2 -arch i386' CC_PRINT_OPTIONS='YES' ac_cv_prog_AWK='awk' CC='/usr/bin/gcc-4.0'
    

    and so on, but my gcc version is

    i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5493)
    

    Is this the issue? Does anyone know how I can get around this?


  • Related Answers
  • crippledlambda

    A simple

    sudo port clean apr
    

    seemed to do the trick. I didn't have to move anything out of /usr/local/ (which seems like a pretty aggressive demand!) http://trac.macports.org/ticket/26809