Using updated GCC?

Discussion in 'Mac Programming' started by brent1a, Sep 18, 2008.

  1. brent1a macrumors member

    Jan 9, 2005
    I've successfully compiled and installed the newest gcc (4.3.2). How do I make Leopard use it now instead of it's default gcc 4.0?
    thanks in advance
  2. darkwing macrumors 65816

    Jan 6, 2004
    You don't want to try and change to a non-apple supplied GCC. They patch it to support their various extensions for OSX. You can use your new gcc to build your posix apps, but if you try and replace your dev tools with it you'll have problems.

    If you want to use it yourself from the command line by default, you should put /usr/local/bin in your path ahead of /usr/bin and /bin. Because Apple sucks, I had to add the following line to my ~/.bash_profile:

    export PATH=/usr/local/bin:$PATH

    (This is assuming you installed gcc-4.3.2 to /usr/local/bin which you should have done.)
  3. brent1a thread starter macrumors member

    Jan 9, 2005
    I definitely don't want to try and replace what Apple has provided. I just want to try and use the new one from the command line.
    However, since I'm a newb at the command line if you could please expound on what exactly I should add to my "sudo ./configure" "sudo make" commands so that I use the gcc-4.3.2 I'd be grateful. I'm not sure I completely understand what you've told me so far.
  4. Cromulent macrumors 603


    Oct 2, 2006
    The Land of Hope and Glory
    Most BSD systems require that as they will only search system paths by default.
  5. brent1a thread starter macrumors member

    Jan 9, 2005
    I understand about adding that to my .bash_profile but where exactly is that at? I can't seem to find it anywhere.

    Can I just do this to add it permanently?

    echo "export PATH=\"/usr/local/bin:$PATH\"" >> .bash_profile
  6. darkwing macrumors 65816

    Jan 6, 2004
    Actually /usr/libexec/path_helper hard codes in the system paths and doesn't let you change their order. So adding /usr/local/bin to the paths won't work because defaults always go first. System level scripts should use absolute paths anyway. For the rest of what you do, you should be able to "replace" your system files by putting new versions or whatever in /usr/local and your own scripts will use those instead.

    brent1a, you can use any text editor or anything to edit your .bash_profile file in your home directory. You will need to use the terminal, however, in order to edit it. You can make it easy on yourself by typing this in terminal:

    open -a TextEdit ~/.bash_profile
  7. brent1a thread starter macrumors member

    Jan 9, 2005
    .bash_profile does not exist?!?!?!

    So I added /usr/local/bin to my .bash_profile however-
    what you are saying is that adding export PATH=\"/usr/local/bin:$PATH\ wouldn't get the results that I would like, having gcc-4.3.2 used instead of the system gcc?

Share This Page