Will installing GCC 4.2.2 (or later) break Xcode etc

Discussion in 'Mac Programming' started by Cromulent, Feb 28, 2008.

  1. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #1
    If I compile and install the latest version of GCC will it cause any problems for Xcode and the other Apple dev tools? I've already upgraded NASM to 2.02 and that seems fine but GCC is such an integral part of the build process I am relucant to do it before I know of any potential problems.

    Thanks for any help :).
     
  2. macrumors member

    Joined:
    Jun 11, 2004
    Location:
    UK
    #2
    Disclaimer: I haven't tried this on Mac OS X, only Solaris and XP.

    Right now we have that out of the way.
    You should be able to specify the install location for your new version of GCC and have two (or more) version installed at the same time with no problems. Then it's all just down to paths as to which one you use.
    I work in embedded software and frequently have multiple compilers installed for cross-compilation to the target(s) as well as for compilation for the host platform

    If you want to get xcode to use the new version, well I can't help you with that one. Would be nice to be allowed to use a mac for work :(
     
  3. thread starter macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #3
    Ah okay, so as long as GCC 4.2.2 goes in /usr/local and the standard build tools remain where they are I can use them interchangably? I was just worried that it would make changes to the libraries or whatever.

    It should be interesting to see if I can get Xcode to compile with the new version, from what I have read Apple make a few changes to GCC which do not help when compiling standard open source code for whatever reason.
     
  4. macrumors member

    Joined:
    Jun 11, 2004
    Location:
    UK
    #4
    That's right. It should be totally self contained.
     
  5. macrumors 6502

    Joined:
    Jun 1, 2006
    #5
    Odds are this is not going to work well, especially with Xcode. In the past I needed a Fortran compiler and was unable to get the Apple provided GCC sources to compile properly with only that added to --enable-languages. I fought with it for a while but finally decided it wasn't worth it and found an alternative solution. Report back and let us know how it goes.
     
  6. macrumors 68000

    GeeYouEye

    Joined:
    Dec 9, 2001
    Location:
    State of Denial
    #6
    It shouldn't break it, as long as you don't overwrite whatever's currently installed. If something fails in Xcode then, just use gcc-select.
     
  7. macrumors regular

    Ti_Poussin

    Joined:
    May 6, 2005
    #7
  8. macrumors G4

    Joined:
    Jan 5, 2006
    Location:
    Redondo Beach, California
    #8
    The libraries and such go into directories that have the the target system name and version number in the name. So you can keep many copies of gcc without need to resort to
    Take a look inside /usr/lib/gcc.
     
  9. thread starter macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #9
    Well my first attempt at compiling GCC did not go too well at all :). It keeps erroring out at the same point. Are there any special steps to take when compiling on Mac OS X? I pretty much just had the standard configure settings. At a bit of a lose really. I'm sure I'll figure it out when I am less tired.
     
  10. macrumors 6502

    Joined:
    Jun 1, 2006
    #10
    Alright, I just compiled gcc 4.2.3. Try doing it with the following commands:

    Code:
    
    ./configure --disable-checking --prefix=/usr/local --enable-languages=c,objc,c++,obj-c++ --build=i686-apple-darwin9 --host=i686-apple-darwin9 --target=i686-apple-darwin9
    
    make -j4
    
    make install
    
    
    I did this on a 2.2GHz MacBook Pro. Change prefix to where you would like it to be installed.
     
  11. thread starter macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #11
    Excellent, thanks for that. I think (I'm at work at the moment) I tried using this for configure when I did it (or something like it, I might have got something a little wrong from memory).

    I guess the problem was in compiling the Ada, Java or Fortran compiler. Shame, I wanted to have a look at Fortran.
     
  12. macrumors 6502

    Joined:
    Jun 1, 2006
    #12
    You may be able to do the Fortran one, I just remember having problems when I tried previously. To compile the Fortran compiler, you will also need to compile GMP and MPFR. I may try it tonight when I get home from work, just out of curiousity.
     
  13. thread starter macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #13
    Excellent. Got it working, thanks for your help :).
     
  14. macrumors 6502

    Joined:
    Jun 1, 2006
    #14
    With the Fortran compiler?
     
  15. macrumors regular

    Joined:
    Jun 9, 2007
    #15
    Fortran is best handled through something like macports. That way you have a complete gcc 4.2.3 suite independent of the system compilers. You can also use a fortran plugin for Xcode and point it at your macports gfortran executable.

    For those of you who aren't familiar with macports or xcode plugins, I detail a science-friendly fresh install of OS X 10.5.2 here:

    http://yocto.wordpress.com/2008/02/27/personal-installation-of-os-x-1052/
     
  16. thread starter macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #16
    No, the only way I could think of doing that was using GCC 4.2.3 to compiler the libraries needed for Fortran and then reinstall GCC with only Fortran selected as the enabled language. The Apple compiler seems to choke on a few open source libraries for some unknown reason.
     

Share This Page