Installing OpenFOAM 2.0.x on Mac OS X Lion

September 1st, 2011 | Posted by admin in Installation | OpenFOAM

# Update on April 2013
New post about OpenFOAM 2.2 on Mac OS X Snow Lion

# Now back to the original post…

As of today, the latest OpenFOAM available is OpenFOAM-2.0.1. I am going to walk through installing it on my Macbook Pro (2.4 Ghz Intel Core 2 Duo). Installing open-source code can be a hassle since hardware/specification varies a lot. But it’s a price to pay, but you can google whenever you encounter a problem. You may find this forum (cfd-online) very useful. I listed

1. Update your OS X to the most recent version. I paid $29.99 for the new OS X Lion (10.7.1) from App Store. (~6 hrs)

2. Go to App Store, and download and install Xcode 4.1 . It’s free, but you have to register as a developer. (~3 hrs)

3. Install Macports for Lion. Simply follow the link and click on Lion to download dmg file. (< 5min)

4. Now you’re ready to install gcc 4.5.3. Open Terminal or X11, and type as followed

>> sudo port install gcc45

It will take a while. (~3 hrs?)

5. Mac OS X 10.7 does NOT come with OpenMPI, so you need to install it. On Terminal, type

>> sudo port install openmpi +gcc45

6. Now we’re ready to install OpenFOAM. Here’s the link for OpenFOAM disk image file for Mac. Download ‘README’ and ‘Mac-OF-2.0.x.sparseimage.zip’.

7. Extract Mac-OF-2.0.x.sparseimage.zip, and mount the image by double clicking.

8. Now, follow the instruction on ‘README’… I’m just going to narrate it here as well. Open Terminal and type..

>> cd ~

>> ln -sf /Volumes/Mac-OF-2.0.x OpenFOAM

>> cd OpenFOAM

>> ln -sf ~/Documents/OF-User ‘whoami’-2.0.x

>> cd ~

>> vi .profile

and add this line

. ~/OpenFOAM/OpenFOAM-2.0.x/etc/bashrc

Quit and restart Terminal…

9. Change the OpenMPI setting…

>>vi ~/OpenFOAM/site/2.0.x/prefs.sh



10. It’s a good idea to recompile it from the beginning.

>> cd ~/OpenFOAM/OpenFOAM-2.0.x


…. this will clear everything up


…. this will take a while…


After few hours of wait, OpenFOAM is finally ready to use. Test drive it by doing one of the tutorials.

You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.

45 Responses

  • Aaron says:

    Hey thanks for the walkthrough. I am installing OpenFoam now. I just wanted to highlight that the quotes around whoami are backticks and not single quotes. It’s more clear in the plain text README file. Thanks.

  • Alucard says:

    Goodmorning, I was following your interesting guide when I start having problems installing gcc45 on my new macbook (with Lion of course)..after 3h of a “strange” compilation,where CPU was at 5% and all the RAM was taken by the process the computer freezed! I tried 4 times thinking it was me the problem, well the problem is instead here https://trac.macports.org/ticket/31604
    So I was wondering how did you manage to install gcc! (it seems anyway some hours ago they found the way,I didn’t have time to test it already).

    • admin says:

      Thanks for replying. As I mentioned in the posting, I simply typed, “sudo port install gcc45” in Terminal.
      How fast is your computer? I was using 2010 Macbook (Intel Core Duo 2.4, 4GB of RAM, etc), and I know it’s not impressive.
      Also, enter “>> gcc –version”, and let me know what it says. Upon successful installation it should say following :

      gcc (GCC) 4.5.3
      Copyright (C) 2010 Free Software Foundation, Inc.
      This is free software; see the source for copying conditions. There is NO

      • Alucard says:

        Goodmoring again,
        I’ve the “last” macbook pro (8.1 Intel i5 with 2.3Ghz,4GB RAM and so on) that comes with the Lion O.S.
        I already checked and the gcc version is still the 4.2 (it’s the default one that comes with Darwin/Xcode).
        About the install procedure: well I just did as you explain, and the Mac is “new”, I only had the time to install Office! so I think I didn’t corrupt any file (I used Linux for many years so I’m still quite new about OsX).
        anyway i’m checking the evolution of the “ticket” over the Macport forum and as I read about a solution I’ll post it here too, I guess it could be helpful.
        Best regards

  • Omar says:

    Thanks for your effort. I am experiencing the same problem Alucard is having. I don’t know why it freezes after several hours of trying to install gcc 45. I think it could be the Xcode 4.2 version. If so, please tell me how to fix that or even how to downgrade to Xcode 4.1 and follow the same instructions you stated.

    I am using Lion on macboob pro (2.7 GHZ and 4GB).
    Thank you again.

  • bambedil says:

    Good Morning,

    I tried to install OF2 on Lion this night, but it failed!!! I Downloaded Xcode4.2, gcc4.5.3 and install gcc45.

    After a while of compiling I get the following message in my terminal:

    ‘/Users/macflo/OpenFOAM/OpenFOAM-2.0.x/platforms/darwinIntel64Gcc45DPOpt/lib/libdistributionModels.dylib’ is up to date.
    + wmake libso genericPatchFields
    wmakeLnInclude: linking include files to ./lnInclude
    Making dependency list for source file genericFvPatchField/genericFvPatchFields.C
    could not open file fvMesh.H for source file genericFvPatchField/genericFvPatchFields.C
    could not open file fvPatchFieldMapper.H for source file genericFvPatchField/genericFvPatchFields.C
    could not open file fvPatchFieldNew.C for source file genericFvPatchField/genericFvPatchFields.C
    could not open file calculatedFvPatchField.C for source file genericFvPatchField/genericFvPatchFields.C

    and so on…

    What could that be???


  • bambedil says:

    Hi once again,

    and if the compilation is ready and I want to start with icoFoam and blockMesh, the terminal output is:
    blockMesh(54518) malloc: *** error for object 0x10adbc580: pointer being freed was not allocated
    *** set a breakpoint in malloc_error_break to debug
    Abort trap: 6

    Thanks in advanced

    • admin says:

      Thanks for sharing your experience. Did you install OpenMPI? Can you go to $OF/OpenFOAM-2.0.x/platforms/darwinIntel64Gcc45DPOpt/lib/dummy, and try >>otool -L libPstream.dylib ?

  • bambedil says:

    Good evening,

    I did “otool -L libPstream.dylib” on my terminal, the output is:

    otool -L libPstream.dylib
    /Users/macflo/OpenFOAM/OpenFOAM-2.0.x/platforms/darwinIntel64Gcc45DPOpt/lib/dummy/libPstream.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
    /opt/local/lib/gcc45/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.14.0)
    /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1094.0.0)
    /opt/local/lib/gcc45/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)

    What can you gather from this output?

    Anyway thanks for your help…

    • admin says:

      otool -L is like “ldd” in linux command. It shows which shared library is pointed (http://linux.about.com/library/cmd/blcmdl1_ldd.htm). I don’t see anything different from mine.
      See if you installed gcc 4.5 correctly. You can check as following..
      >>gcc –version
      gcc (GCC) 4.5.3
      Copyright (C) 2010 Free Software Foundation, Inc.
      This is free software; see the source for copying conditions. There is NO

  • Omar says:

    I have followed the instructions from the same ticket Alucard stated and finally i was able to install gcc 45 . Therefore i would like to post all terminal commands in here:
    sudo port -f uninstall gcc45 gawk
    sudo port -f uninstall rdepof:gcc45
    sudo port clean –all rdepof:gcc45 gcc45
    sudo port install gcc_select xz gmp
    sudoport install mpfr configure.compiler=llvm-gcc-4.2
    sudo port install gcc45
    sudo port clean –all gawk
    sudo port install gawk
    now I’m in the process of installing openMPI and then completing the rest of your instructions.
    All the best,,

    • admin says:

      Thanks for sharing!! I’m sure many people will benefit from this comment! I guess you’ve finished compiling ? Happy research!

    • Alucard says:

      Hi again,
      yes I tried yesterday the solution contained in the Macport “ticket” and I compiled gcc45.
      I followed a different way respect to Omar:

      sudo port clean gcc45
      sudo port selfupdate
      sudo port upgrade outdated
      sudo port install gcc45

      and it worked for me too so we can safely say that the gcc+openmpi step is cleared now.
      I still have some problems with the openfoam installation (perhaps it’s me, I’m never lucky with installations).
      As I had to work at home with OF, I installed for the moment ubuntu+openfam in virtualbox (it runs smooth for small developpement OF codes) …but I’ll continue to try the OF installation in these days!

  • Felipe says:

    Hi Admin

    How did you select gcc45 for the compilation?

    doing “sudo port select gcc gc-mp-4.5″ does not work for me, so when I try to compile everything after installing ” sudo port install openmpi +gcc45″ does not work.



  • Sandeep says:

    i couldn’t implement step number: . pasting in profile “~/OpenFOAM/OpenFOAM-2.0.x/etc/bashrc”…terminal shows E$^*: Pattern not found OpenFOAM

    untill this step everything went fine…please help

    • admin says:

      Hi Sandeep, Thanks for visiting.
      Did you load the Mac-OF-2.0.x.sparseimage file and redirect it to ~/OpenFOAM? (Step 8).
      Can you access ~/OpenFOAM/OpenFOAM-2.0.x/etc/bashrc ?
      Try “source ~/OpenFOAM/OpenFOAM-2.0.x/etc/bashrc” on terminal. By adding “.~/OpenFOAM/OpenFOAM-2.0.x/etc/bashrc” in ~/.profile, that command is run as terminal opens.

  • Aucard says:

    Goodmorning again,
    I come back to the OF installation after a while and after I watched the good video here.
    Well, I’ve still a problem with gcc!!
    Last time I said I was able to compile it and well, the problem is that it’s compiled (or it seems) but when I check the version I still see the 4.2 that originally comes with Xcode..if I try again sudo port install gcc45 I have the same results than in the video (it states gcc45 is already installed) So how can I configure the right gcc in order to see 4.5.3 when I type “gcc –version” ??

    • Aucard says:

      Ok I solved it you’ve to change de symbolic link to gcc in /usr/bin
      so you do:

      cd /usr/bin/
      sudo rm cc gcc c++ g++

      sudo ln -s /opt/local/bin/cc-mp-4.5 /usr/bin/cc
      sudo ln -s /opt/local/bin/gcc-mp-4.5 /usr/bin/gcc
      sudo ln -s /opt/local/bin/g++-mp-4.5 /usr/bin/g++
      sudo ln -s /opt/local/bin/c++-mp-4.5 /usr/bin/c++

      this should set you the 4.5.3 version as the default one (as you see in the video)

  • med says:


    Thank you so much for this tutorial ! I have been able to follow all the steps in a breeze.
    Once I sourced the bashrc, I have encountered problems with the paraFoam utility:

    jadwifi246:damBreak med$ paraFoam
    /Applications/ParaView 3.10.1.app/Contents/MacOS/paraview –data=/Users/med/Working/OpenFOAM/interFoam/laminar/damBreak/damBreak.foam
    dyld: Symbol not found: _iconv
    Referenced from: /usr/lib/libcups.2.dylib
    Expected in: /opt/local/lib/libiconv.2.dylib
    in /usr/lib/libcups.2.dylib
    /Users/med/OpenFOAM/OpenFOAM-2.0.x/bin/paraFoam: line 236: 28487 Trace/BPT trap: 5 “/Applications/ParaView 3.10.1.app/Contents/MacOS/paraview” –data=`pwd`/”$caseFile”

    I can manage to make it work with


    But, this generates others problems, like when using decomposePar:

    jadwifi246:damBreakFine med$ decomposePar
    dyld: Library not loaded: libscotch.dylib
    Referenced from: /Users/med/OpenFOAM/OpenFOAM-2.0.x/platforms/darwinIntel64Gcc45DPOpt/lib/libscotchDecomp.dylib
    Reason: image not found
    Trace/BPT trap: 5

    Any keys ?

  • art says:

    hello. installed gcc45 and openmpi fine, have latest version of Xcode. the ‘wcleanAll’ works fine and the ‘Allwmake’ runs for a long time, looking like it’s compiling fine. After a while, start getting:
    Target `application’ not remade because of errors.
    for multiple libraries.
    Any suggestions? thanks.

    • Matt says:


      I’m having the same problem that you’re having, i think. Just wondering if you had any luck installing, and what you did to fix it. Any help would be appreciated.


  • justanoob says:

    I have just a maybe stupid question:
    what exactly is the symbolic link for that is created by

    >> ln -sf ~/Documents/OF-User ‘whoami’-2.0.x

    if the directory OF-User… does not exist, this link stays empty but nowhere in the description you mention to create this directory.
    Thanks for an answer.

  • Matt says:

    This might be kind of a dumb question but did anyone need to use the patches on this page? I’m still not able to compile without getting errors like


    target ‘application’ not remade because of errors.

    Any help would be appreciated.

  • Pierre says:

    I am finishing the installation of OpenFoam on my Macbook which works under Snow Leopard.
    When I try to use blockMesh, I get the following :
    blockMesh(1959) malloc: *** error for object 0x7fff7057d500: pointer being freed was not allocated
    *** set a breakpoint in malloc_error_break to debug
    Abort trap

    I read the previous topics, and by using otool -L libPstream.dylib, I get :
    /Users/sushant/OpenFOAM/OpenFOAM-2.0.x/platforms/darwinIntel64Gcc45DPOpt/lib/dummy/libPstream.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.10)
    /opt/local/lib/gcc45/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.14.0)
    /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 832.0.0)
    /opt/local/lib/gcc45/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)

    What can I do ?
    Thanks in advance,

  • shaun says:

    Hi. I have been following your instructions and I think I have done everything correctly. The only thing different was to add ~/OpenFOAM/OpenFOAM-2.0.x/etc/bashrc to .bash_profile instead of .profile

    With regards to step 10.
    wcleanAll didn’t exist in the image in ~/OpenFOAM/OpenFOAM-2.0.x so I copied it from ~/OpenFOAM/OpenFOAM-2.0.x/wmake
    When I ran the command, it gave a few error messages

    After that I tried to run ./Allwmake
    I always get the following error.

    ./Allwmake: line 4: wmakeCheckPwd: command not found
    Error: Current directory is not $WM_PROJECT_DIR
    The environment variables are inconsistent with the installation.
    Check the OpenFOAM entries in your dot-files and source them.

    Do I need to set the WM_PROJECT_DIR in my .bash_profile?


    • admin says:

      Hi Shaun.

      No, you don’t have to set WM_PROJECT_DIR in your ~/.bash_profile Did you source the bashrc from OpenFOAM itself? It should automatically set bin directories required.
      $ source ~/OpenFOAM/OpenFOAM-2.0.x/etc/bashrc
      and put this line in your ~/.bash_profile

      Hope it helped.

      • Jagan says:


        I am having similar problems when installing Openfoam on to Mac.

        When I add these line I get the following problem mpicc: Command not found. Could you please let me know do I have to add anything else to my .bash_profile.


      • tom says:

        sorry ive also the Problem with the last part
        ./Allwmake: line 4: wmakeCheckPwd: command not found
        what can i do?

      • Suresh Raja says:

        I had the source pointing to the wrong folder. Fixing it to the right folder (OpenFOAM 2.2.2) in bash_profile fixed the issue.

  • milad says:

    I just started to work with Open FOAM my Macbook pro softwares are:
    Mountain Lion- Xcode 4.4.1- I Installed the Macports for Mountain lion
    the terminal respond to sudo port install gcc45 is Error: Port gcc45 not found
    what should I do exactly?

  • Alie says:

    What if I have Mountain Lion.

  • alan says:


    I followed all the steps with no major problem, however when trying to edit usinf this command… vi ~/. profile … i get, profile[NEW PROFILE] … im sure its an error as the outcome on the video is different. Any ideas? If you can find me spot the error maybe it could help other users. Thanks a lot. Great video and instructions!


  • alan says:

    Is it necessary to make a case sensitive partition? once again thanks for any support you can provide.
    Best regards


  • Tom Sturges says:

    I have followed all steps successfully apart from…. I am in directory: /Users/tomsturges/OpenFOAM/OpenFOAM-2.0.x

    When I type >>wcleanAll terminal says -bash: wcleanAll: command not found

    what to do?

    thanks for any help =)

    • Russell Dow says:

      Yes, I have the same problem:

      Russells-MacBook-Air:~ Russell_Dow$ cd ~/OpenFOAM/OpenFOAM-2.2.0
      Russells-MacBook-Air:OpenFOAM-2.2.0 Russell_Dow$ wcleanAll
      -bash: wcleanAll: command not found

      Is there something that I am doing incorrectly?

      • admin says:

        Thanks for your visit. Those commands like wmake, wclean, and wcleanAll are only available once you source the OpenFOAM bashrc file. If you type in source ~/OpenFOAM/OpenFOAM-2.2.0/etc/bashrc or enter that line on your ~/.profile, you should be good to go.


  • Pingback: installation on mac os x lion -- CFD Online Discussion Forums

  • Dave says:

    Hi – thank you for this tutorial.
    I believe I have followed all instructions but when i enter ‘blockMesh’ into the terminal window, the bash command is not found.
    Is there a way to diagnose this error? All files appear to be located in the correct place – I have tried a few of the checks above but and all appears correct.

    • admin says:

      The chances are that it’s either because OpenFOAM was not compiled correctly, or you forgot to source ~/OF/etc/bashrc. They just announced newer version of OpenFOAM (2.2.0), so why don’t you try it again with more recent one? I’ve uploaded the video tutorial as well. Thanks

Leave a Reply

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


Please enter the CAPTCHA text