I had some trouble getting OpenKIM up and running on a MacBook with OS X Lion 10.7.3. In case others have the same problem, here is how I did it.
1. I got rid of the old Macports (google macports uninstall) since it does not provide gfortran except in a very experimental version.
2. Install Homebrew, see https://github.com/mxcl/homebrew/wiki
3. Run "brew doctor" and fix the issues it reports. Even if they look innocent, they may cause a considerable waste of time later - I speak from experience.
4. Install gfortran ("brew install gfortran").
5. Now the trouble begin:
5A. The default Mac compilers are LLVM versions (whatever that means). They will not play nice with gfortran! Change the Makefile to use gcc-4.2 and g++-4.2 instead of gcc and g++
5B. The Homebrew gfortran compiler work fine by itself, but the C/C++ compiler can't find its libraries. Add the directory /usr/local/lib/gcc/i686-apple-darwin11/4.2.1 to the linker search path (as compilers are updated, this will change).
5C. The C++ compiler cannot link fortran. Use the fortran compiler to link.
The changes in 5A to 5C are all in KIM_API/GNU_compiler_settings.mk, here is the diff:
--- ../openkim-api-v1.0.0.orig/KIM_API/GNU_compiler_settings.mk 2012-02-22 23:09:04.000000000 +0100
+++ KIM_API/GNU_compiler_settings.mk 2012-02-24 20:32:05.000000000 +0100
@@ -40,8 +40,8 @@
-D KIM_DIR_MODELS=\"\(KIM\_MODELS\_DIR\)\\" \\ \-D KIM\_DIR\_TESTS=\\"(KIM_TESTS_DIR)\" \
-D KIM_DIR_MODEL_DRIVERS=\"\(KIM\_MODEL\_DRIVERS\_DIR\)\\" \- CCOMPILER = gcc \- CPPCOMPILER = g\+\+ \+ CCOMPILER = gcc\-4\.2 \+ CPPCOMPILER = g\+\+\-4\.2 \#CCOMPILER = mpicc \#CPPCOMPILER = mpiCC \#CCOMPILER = gcc\-fsf\-4\.4 \# for OS X using fink compilers @@ \-54,10 \+54,10 @@ \-D KIM\_DIR\_MODEL\_DRIVERS=\\"(KIM_MODEL_DRIVERS_DIR)\"
FORTRANCOMPILER = gfortran
#FORTRANCOMPILER = mpif90
- CPPLIBFLAG = -lgfortran #if GNU version 4.5 and up. tested on suse
- LINKCOMPILER = \(CPPCOMPILER\) \#if GNU version 4\.5 and up\. tested on suse \- \#CPPLIBFLAG = \-lstdc\+\+ \#if GNU version 4\.4\.1\. tested on suse \- \#LINKCOMPILER = (FORTRANCOMPILER) #if GNU version 4.4.1. tested on suse
+ CPPLIBFLAG = -L/usr/local/lib/gcc/i686-apple-darwin11/4.2.1 -lgfortran #if GNU version 4.5 and up. tested on suse
+ #LINKCOMPILER = \(CPPCOMPILER\) \#if GNU version 4\.5 and up\. tested on suse \+ CPPLIBFLAG = \-lstdc\+\+ \#if GNU version 4\.4\.1\. tested on suse \+ LINKCOMPILER = (FORTRANCOMPILER) #if GNU version 4.4.1. tested on suse
CPPLIBFLAG += -ldl
(If you are not familiar with a diff output: Change the lines prefixed with - into the lines prefixed with +. Do it manually, or automatically by piping the entire email into "patch -p0" while standing in the top OpenKIM directory:
cat email.txt | patch -p0
(it is a zero after the p)