Chip Freitag



A very common question we receive through the ACML support channels is how to use ACML with different versions of GCC/GFORTRAN. Since the ACML team does not have the resources to provide a current version of ACML built with every possible GCC version, we have to choose which GCC version to build with. In general the choices are driven by which GCC is available through the common distributions, but it can also be driven by features provided by those compilers.

Many systems have GCC 4.1.2 as the default. Recent ACML versions are built with newer compilers, since 4.1.2 did not support OpenMP.

A primary incompatibility is the version of libgfortran required by the ACML library. Newer versions require   GCC4.1.2 included It might be possible to copy a recent from another machine, but this is not a recommended solution. A better solution is to install or build a new GCC/GFORTRAN.

Not every user has the luxury of being able to install a new compiler on the computer being used. But there is a relatively simple way to build a private copy of a GCC version when it is needed to resolve compatibility issues for ACML and other applications. These private c90opies can be built and installed in a user directory, and kept isolated from the system libraries.

Here are the steps for building GCC versions in ways that are known to work properly for ACML. These steps are for a 64-bit build.

  1. Download (mirrors listed at the new gcc package and extract to a local directory. For instance if the home directory is /home/acmluser, it will extract to
  2. build/install mpfr
    GFORTRAN requires mpfr. You can skip this step and try to just build the compiler. If libmpfr is not there, the compiler configure step will fail. In that case, come back to this step.

    The mpfr source package can be downloaded from The build steps that worked for me were

    make install

    Of course the install step requires root privilege if installing into the default locations. the –prefix options can specify different install locations.

    On some REDHAT systems, I ran into a compatibility issue with the default libmpfr.a.

    I had to remove the existing file from /usr/lib/libmpfr.a and then ensure LD_LIBRARY_PATH and LD_RUN_PATH included paths to the location of the new mpfr, usually /usr/local/lib.

  3. Create build and install directories for the new compiler. These choices are arbitrary and can be anything you want. Examples would be something like:
    /home/acmluser/build441 and /home/acmluser/gcc441
  4. cd to /home/acmluser/build441
    There is nothing in this directory yet. There soon will be.
  5. Build GCC with gfortran options. You can add other options if needed, but I never found the need to test ACML with ada,
    1. configure with
      /home/acmluser/gcc-4.4.1/configure –prefix=/home/acmluser/gcc441 –enable-shared –enable-languages=c,c++,fortran
      The –prefix option is telling the configure step that the final destination will be in your gcc441 directory. You execute this command in the build directory, and that will cause all the temporary files to be placed in the build directory.
      After this step, the gcc441 directory will still be empty.
    2. make
      It’s that simple. This will take a while, 20 minutes to an hour.
      After this step, the gcc441 directory will still be empty.
    3. make install
      Now the gcc441 directory will have files in it.
  6. Create a set environment script file (with +x permissions) in /home/acmluser/gcc441. This file could be anywhere, but that’s convenient location.
    Here is an example of the contents.

    # Set GCC environment variables.
    if [ -z "${PATH}" ]
    export PATH=$GCCPATH/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin
    export PATH=$GCCPATH/bin:${PATH}
    if [ -z "${LIBRARY_PATH}" ]
    export LIBRARY_PATH=$GCCPATH/lib64:$GCCPATH/lib/gcc/x86_64-unknown-linux-gnu           /$GCCVER
    export LIBRARY_PATH=$GCCPATH/lib64:$GCCPATH/lib/gcc/x86_64-unknown-linux-gnu           /$GCCVER:${LIBRARY_PATH}
    if [ -z "${LD_LIBRARY_PATH}" ]
    export LD_LIBRARY_PATH=$GCCPATH/lib64:/usr/local/lib64
    if [ -z "${LD_RUN_PATH}" ]
    if [ -z "${MANPATH}" ]
    export MANPATH=$GCCPATH/man
    if [ -z "${INFOPATH}" ]
    export INFOPATH=$GCCPATH/info
    export CPATH=$GCCPATH/include:$GCCPATH/lib/gcc/$GCCARCH/$GCCVER/include
    export CPLUS_INCLUDE_PATH=$GCCPATH/include/c++/$GCCVER:$GCCPATH/lib/gcc/$GCCARCH/$GCCVER/include
  7. As a user, source the setenv file. Which gcc and gcc -v can be used to verify the correct compiler is being used.
  8. Now you are ready to use the new compiler. Let us know if you find this useful in your work.