Install GCC 3.1 on 10.1.5

Jul 23, '02 09:05:44AM

Contributed by: c15zyx

This quick guide will allow you to install GCC 3.1 (Free Software Foundation version, not Apple's) along with the C, C++, and objective-C compilers. This is useful if you want to test out your code before Apple's release of GCC3 in Jaguar (10.2). Features of 3.1 include faster compilation, better code optimization, a new C++ library, and better support for the ANSI code standards.

However, there are some problems with this release. GCC will not recognize some compiler flags and the dynamic linker does not work with this build - you will often have to link statically and configure software with the "--disabled-" shared flag. If anyone knows how to get around these problems, feel free to post in the comments.

Read the rest of the article for the how-to (the Dev Tools are required)...

NOTE: Compiling GCC can take several hours depending on your machine's speed, so plan accordingly.

  1. Go to the mirrors page and select one of the mirrors.

  2. Go to 'releases', then 'gcc-3.1' then download 'gcc-3.1.tar.bz2' (about 20MB).

  3. After expanding (about 150MB), open the file gcc-3.1/gcc/ginclude/stddef.h in a text editor (recommend Project Builder or pico).

  4. Below the line
    #ifndef _SIZE_T_DEFINED
    Add
    #ifndef _BSD_SIZE_T_DEFINED_
  5. Below the line
    #define _SIZE_T_DEFINED
    Add
    #define _BSD_SIZE_T_DEFINED_  /* for Darwin */
  6. Below the line
    #endif /* ___int_size_t_h */
    Add
    #endif /* _BSD_SIZE_T_DEFINED_ */
  7. Save, then open the file gcc-3.1/libstdc++-v3/include/c_std/std_cctype.h in a text editor.

  8. Below the line
    #undef toupper
    Add
    /* APPLE LOCAL begin supply missing ctype.h decls 2001-07-11 sts */
    /* These are supposed be in ctype.h like the standard says! We need
    this until Darwin ctype.h gets fixed and/or GCC has a fixincludes
    to supply these if they're missing. */
    extern "C" {
    extern int isalnum(int c);
    extern int isalpha(int c);
    extern int iscntrl(int c);
    extern int isdigit(int c);
    extern int isgraph(int c);
    extern int islower(int c);
    extern int isprint(int c);
    extern int ispunct(int c);
    extern int isspace(int c);
    extern int isupper(int c);
    extern int isxdigit(int c);
    }
    /* APPLE LOCAL end supply missing ctype.h decls 2001-07-11 sts */
  9. Save, and in the Terminal navigate to the gcc-3.1 directory (VERY IMPORTANT!)

  10. Type
     % limit stacksize 3072
    % mkdir ../gcc_build;cd ../gcc_build
    % ../gcc-3.1/configure --enable-languages='c,c++,objc'
    % make bootstrap-lean
    % sudo make install
  11. Once installed, you can remove the gcc_build directory. If you want to use the Apple 2.95 compiler, use the command "cc".

    Altivec Notes:
    There is a configure option that is supposed to enable Altivec support for the ABI, but does not compile properly.

    From GCC 3.1 Changes:
    Aldy Hernandez, of Red Hat, Inc has contributed extensions to the PowerPC port supporting the AltiVec programming model (SIMD). The support, though presently useful, is experimental and is expected to stabilize for 3.2. The support is written to conform to Motorola's AltiVec specs. See -maltivec. Because I have a G3 system, I have not tested using the -maltivec flag.

    [Editor's note: I have not tested this, and I hope that I haven't messed up any of the commands during the formatting process. If you see something that doesn't look right, please let me know...]

    Comments (10)


    Mac OS X Hints
    http://hints.macworld.com/article.php?story=20020723090544155