Apparently installing deal.II (finite element library) on a Mac, seems like a fairly straightforward thing, in practice it took me a loot of time to do it because there was one very nasty thing that had to be done and it was not at all obvious. So I try here to give a walkthrough of all the steps I took to install deal.II on my mac. I installed it with MPI, so that I could use the multiprocessing capabilities.PRE-REQUISITESIn order to install deal.II you need to have installed some other packages:
- LAPACK and BLAS
- OpenMPI (v1.3.3)
- Boost (v1.4.0)
- PETSc (v2.3.3)
Let’s do it by parts, you should follow this order of installation:Directory structureI decided to install all libraries, except the compiler and LAPACK and BLAS on my home directory. I put all my source files and downloaded archived on a folder:~/Programs/srcAll the installed libraries I put them on a folder inside:~/Programs/installSo, most probably you do not have this directory structure hence open a terminal window and do the following to create these directories:
3
| mkdir ~/Programs/install |
LAPACK and BLASIn order to compile anything you need a compiler, hence you need something like the gcc collection. You can use some other compilers but I haven’t tried them. The easiest way to get up and running with compilers on a mac it’s by installing Xcode and the Xcode gFortran plugin. With this you get the gcc collection and also gfortran.For free you also get an optimized version of LAPACK and BLAS with vecLib. Hence you don’t need to have any additional work in order to have LAPACK and BLAS installed.OpenMPII installed version 1.3.3. You can dowload it from here. You can either download it from the browser and put it in the ~/Programs/src folder or you can go to the terminal and do:
2
| wget http://www.open-mpi.org/software/ompi/v1.3/downloads/openmpi-1.3.3.tar.gz |
After this just extract the contents of the archive:
3
| tar xvf openmpi-1.3.3.tar.gz |
Now go inside the newly created directory:
Run configure with the prefix to the directory where we want to install openMPI, in this case inside ~/Programs/install/openmpi:
5
| ./configure --prefix=~/Programs/install/openmpi |
This should configure all the compilation variables with no problem so, after all the output just start compiling:
Then install:
If everything went fine you should have openMPI installed properly. Now it is only necessary to update your PATH and some other environment variables. To do that you need to edit your .bash_profile file, hence to do it type:
Once emacs is open with your .bash_profile file, just add the following lines to it:
# Set up environment variables for openmpiexport PATH=/Users/gorkiana/Programs/install/openmpi/bin:${PATH}export LD_LIBRARY_PATH=/Users/gorkiana/Programs/install/openmpi/lib:${LD_LIBRARY_PATH}export LD_LIBRARY_PATH=/Users/gorkiana/Programs/install/openmpi/lib/openmpi:${LD_LIBRARY_PATH}export LD_LIBRARY_PATH=/Users/gorkiana/Programs/install/openmpi/include:${LD_LIBRARY_PATH}export LD_LIBRARY_PATH=/Users/gorkiana/Programs/install/openmpi/include/openmpi/ompi/mpi/cxx/:${LD_LIBRARY_PATH}export DYLD_LIBRARY_PATH=/Users/gorkiana/Programs/install/openmpi/lib:${DYLD_LIBRARY_PATH}export DYLD_LIBRARY_PATH=/Users/gorkiana/Programs/install/openmpi/lib/openmpi:${DYLD_LIBRARY_PATH}
Notice that /Users/gorkiana/Programs/install… is for my own computer, my username is gorkiana, so you should put your own username instead of gorkiana. Save it with control+x+s and exit with control+x+c.Now run your updated bash_profile:
Now you should have a properly working openMPI. To check if in fact it is, move inside the examples directory:
And make all the example programs:
Run some of the examples, for example:
You should get something like this as output:
13
| Hello, world, I am 0 of 2 |
14
| Hello, world, I am 1 of 2 |
If you get this you have a well installed OpenMPI! Next step.BoostI installed version version 1.4.0. You can download it from here. You can either download it from the browser and put it inside your ~/Programs/src folder or you can go to the terminal and type:
1
| wget http://downloads.sourceforge.net/project/boost/boost/1.40.0/boost_1_40_0.tar.gz?use_mirror=kent |
After that you must extract the contents of the archive, for that do:
2
| tar xvf boost_1_4_0.tar.gz |
Move to the extracted directory:
Run the configuration script:
4
| ./bootstrap.sh --prefix=~/Programs/install/boost_1_4_0 |
Edit the file ./user-config.jam:
5
| emacs ./user-config.jam |
Add the following line: using mpiSave and exit with control+x+s and control+x+c.Build Boost and install it:
Now you just need to add some directories to the environment variables by editing your .bash_profile file. Type:
And add the following lines:
# Set up environment variable for boost_1_4_0export LD_LIBRARY_PATH=/Users/gorkiana/Programs/install/boost_1_4_0/lib:${LD_LIBRARY_PATH}export LD_LIBRARY_PATH=/Users/gorkiana/Programs/install/boost_1_4_0/boost/include:${LD_LIBRARY_PATH}export LD_LIBRARY_PATH=/Users/gorkiana/Programs/install/boost_1_4_0/boost:${LD_LIBRARY_PATH}export DYLD_LIBRARY_PATH=/Users/gorkiana/Programs/install/boost_1_4_0/lib:${DYLD_LIBRARY_PATH}
Save and exit with: control+x+s and control+x+c.You should now have a working installation of Boost! Next step…PETScI installed version version 2.3.3. You can download it from here. You can either download it from the browser and put it inside your ~/Programs/src folder or you can go to the terminal and type:
2
| wget http://ftp.mcs.anl.gov/pub/petsc/software_old/petsc-2.3.3.tar.gz |
After that you must extract the contents of the archive, for that do:
2
| tar xvf petsc-2.3.3.tar.gz |
Move to the extracted directory:
Now you need to set up some environment variables for PETSc:
4
| export PETS_DIR=~/Programs/src/petsc-2.3.3-p15 |
5
| export PETS_ARCH=macosx |
Run the configuration program:
6
| python ./config/configure.py --prefix=~/Programs/install/petsc-2.3.3 --with-blas-lapack-lib="-framework vecLib" --with-mpi-dir=~/Programs/install/openmpi/ --with-shared=1 --with-debugging=0 |
This says that one should use the vecLib LAPACK and BLAS libraries, the openmpi installation that we just did, generate shared libraries and don’t build debugging libraries, that is, build optimized libraries. Good for production code, faster.Now build it:
VERY IMPORTANTYou should see a lot of output. When it finishes you should check if there was any error in the end stating that it was unable to make the shared libraries. You can also check if you have any .dylib files (shared libraries) in the directory ~/Programs/src/petsc-2.3.3-p15/lib/macosx. Just type:
8
| ls ~/Programs/src/petsc-2.3.3-p15/lib/macosx | grep .dylib |
If you get several files, than you are ok, if not, then you need to do the following. This is very important since if you do not have this files, you are stuck in this step and you are unable to build deal.II. This was what took me a lot of time to solve. Thank you Wendy Mason from the Underworld project for the helpful solution!If you do not have the dylib files you need to edit the file ~/Programs/src/petsc-2.3.3-p15/bmake/common/rules.shared.based, doing:
9
| emacs ~/Programs/src/petsc-2.3.3-p15/bmake/common/rules.shared.based |
Search for a line where there is something like shared_darwin8: shared_darwin7 and add the following line after that one:
10
| shared_darwin9: shared_darwin7 |
Save the file and exit with control+x+s and control+x+c.Make the shared libraries with:
11
| make PETSC_ARCH=macosx shared |
Now this should work and you should have the shared libraries. Redo:
12
| ls ~/Programs/src/petsc-2.3.3-p15/lib/macosx | grep .dylib |
And confirm that in fact you have the .dylib files you need.Just install it:
Now you just need to add some directories to the environment variables by editing your .bash_profile file. Type:
And add the following lines:
# Set up environment variables for pets-2.3.3export PATH=~/Programs/install/petsc-2.3.3/bin:${PATH}export LD_LIBRARY_PATH=~/Programs/install/petsc-2.3.3/lib/macosx:${LD_LIBRARY_PATH}export LD_LIBRARY_PATH=~/Programs/install/petsc-2.3.3/include:${LD_LIBRARY_PATH}export PETSC_DIR=~/Programs/install/petsc-2.3.3export PETSC_ARCH=macosx
Save and exit with: control+x+s and control+x+c.Run you new bash_profile:
You should now have a working installation of PETSc! Next step.deal.III installed version version 6.2.1. You can download it from here. You can either download it from the browser and put it inside your ~/Programs/src folder or you can go to the terminal and type:
2
| wget http://www.dealii.org/download/deal.nodoc-6.2.1.tar.gz |
After that you must extract the contents of the archive, for that do:
3
| tar xvf deal.nodoc-6.2.1.tar.gz |
Move to the extracted directory:
Run the configuration script:
5
| ./configure CC=mpicc CXX=mpicxx --with-boost-include=/Users/gorkiana/Programs/install/boost_1_4_0/include/boost --with-boost-lib=/Users/gorkiana/Programs/install/boost_1_4_0/lib LIBS="-framework vecLib" |
Notice that one has to give the MPI compilers no the default ones. If you do not do this, then you will get an error stating that it cannot find some MPI functions. Also you need to give Boost directories and LAPACK and BLAS connected to vecLib, the Apple provided optimized version of LAPACK and BLAS.The configuration process should work fine, after this you just need to build:
You should now have a working installation of deal.II.

This entry was posted
on Monday, September 21st, 2009 at 10:37 am and is filed under mac, programming.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
September 21st, 2009 at 10:17 pm
FWIW, you can “make -j 4 all” to build Open MPI a bit faster.
September 22nd, 2009 at 8:50 am