Compiling mpich2 on OSX (and targeting the OSX 10.5 SDK)

Posted on


I am compiling mpich2 1.4.1p1 for OSX and using -sysroot to direct the compilers to link against the SDK for 10.5. I do the following in a script to avoid typing this all out every time. As you can see, I’ve gotten desperate in the environment variables and using everyone I can find in their README (except fortran ones which I am disabling).

export CFLAGS="-isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5"
export CPPLAGS="-isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5"
export LDFLAGS="-isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5"
export CXXFLAGS="-isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5"
export LIBS="-isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5" 
../configure --with-pm=gforker --enable-fast=O3 --disable-f77 --disable-fc --prefix=/opt/mpich2/64/ 

Unfortunately, the compiled version does not link with SOME of the libraries in the OSX10.5 directories.

otool -L /opt/mpich2/64/bin/mpiexec
    /opt/local/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.6.0)
    /opt/local/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
    /opt/local/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.4)
    /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)

The iconv library in the SDK is 7.0.0,

otool -L /Developer/SDKs/MacOSX10.5.sdk/usr/lib/libiconv.2.dylib 
    /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
    /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.0.0)

I’m trying to distribute against this application and most of the OSX machines I’ve tested on here at the lab have libiconv version 7.0.0. I do not want this to be a requirement in my distribution.

Grep’ing the source of mpich, I can see the logs and makefiles that are using the wrong version, with a spattering of -L/opt/local/lib/ sprinkled throughout the hydra and doxygen build process.

What environment variables am I missing? I realize this is a complex build script and someone skipping a convention is of high probability. I’ll continue to hunt through the makefiles. And I’ll see if using sed to replace every instance of -L/opt/local/lib/ with the path I really want fixes the issue.


I decided to build 1.4 and 1.3 to see if the issue resides there.

Thankfully 1.4 built and ran fine. It looks as though iconv is statically linked in that version of mpich2 –running otool -L mpiexec did not even include libiconv as a dependency.

Leave a Reply

Your email address will not be published. Required fields are marked *