Installation/Outdated/Howto compile OpenFOAM

From OpenFOAMWiki

This document describes how to compile OpenFOAM on Unix from the source code provided by the nice folks at OpenCFD.

This document also describes how to download and compile some of the tools or packages needed for compiling OpenFOAM.

The process described in this document is based on the OpenFOAM README file, Section "4. Building from Sources (Optional)", but with more details.

The information presented here has been tested and validated by the author while compiling OpenFOAM 1.3, under SuSE 9.1 x86_64, RedHat/Centos 4 and Debian/Knoppix 5.0, and more recently with OpenFOAM 1.4 on the same RedHat system. Depending on your Operating System and/or your OS version, your milleage may vary...

Furthermore, the version numbers for the different packages involved in the recompilation of OpenFOAM are different for OpenFOAM version 1.3 and 1.4; please use the packages source code version associated with the binary package proposed by OpenCFD when upgrading and compiling a newer version of OpenFOAM. The current text is based on the packages version recommended for OpenFOAM 1.3.

This is work in progress; please don't hesitate to complement the information presented here.


1 Preamble

1.1 Basic stuff

This document describes the compilation and installation of OpenFOAM 1.3 in the default installation directory $HOME/OpenFOAM and $HOME/OpenFOAM/linux, as suggested in http://www.openfoam.org/download.html.


If not already available, you first need to create these directories:


For x86:

 
mkdir -p $HOME/OpenFOAM/linux


For x86_64:

 
mkdir -p $HOME/OpenFOAM/linuxAMD64


For the rest of this document, only the x86 installation procedure will be presented in detail. The specific information for the installation on x86_64 platforms will be presented only when significantly different from the x86 installation procedure.

1.2 Not so basic (but very useful) stuff

In the process of recompiling and installing OpenFOAM 1.3, you will have to modify some of the files provided by OpenCFD.

Before doing so, I highly recommend archiving the original version of the file under RCS first.

RCS stands for Revision Control System. It's a revision control system that is the ancestor of the well known CVS and Subversion revision systems. RCS comes standard with probably almost every modern flavors of Unix.

The nice thing about RCS is its simplicity, the fact that it stores the file revision archive locally, and most importantly, it's a system that will help you memorize every revisions of any given ASCII file, so you will always be able to return any modified file back to a known and valid version.

So, take the time to RTFM about RCS (eg: man rcs). It might save you some headaches later on.

1.3 Finally, a little advice

As a rule of thumb, do not install OpenFOAM as the user root on your workstation. Instead, use your own username, or simply create a new user openfoam. The super-user root should always be reserved for doing system administration tasks.


2 Compiling and installing GNU Gcc

2.1 The motivation for compiling GNU gcc

Compiling the GNU gcc/g++ compiler can be a daunting task for the non-initiated. Usually, the installation of the pre-compiled gcc/g++ binary package offered by OpenCFD with any new release of OpenFOAM should cover the need of most OpenFOAM developers.

As mentioned on the mailing list by Hrvoje Jasak, it is usually recommended to keep your OpenFOAM gcc/g++ compiler very up-to-date because a new gcc/g++ release usually means fewer compiler bugs and better performance; OpenFOAM will usually benefit from the newer compiler. So this is one very good reason to visit the GNU gcc compiler web site regularly, and recompile gcc/g++ from the source code.

However, another good reason for recompiling gcc/g++ is related to some compatibilities issues that can arise when deploying the OpenCFD pre-compiled gcc/g++ package on your platform.

One issue that I have encountered on a SuSE 9.1 platform with the pre-compiled gcc/g++ binary package was related to the interaction of the new g++ compiler and the system GNU linker ld. Both the gcc/g++ compiler and the ld linker are necessary when compiling applications on Unix. And of course, they both need to be compatible with one another.

To make a long story short, when configuring gcc/g++, the configure script will automagically explore the availability of the numerous runtime options of your system GNU linker ld, and compile gcc/g++ accordingly. On recent operating systems like SuSE 10, the version of system linker ld is newer, hence new runtime ld options are available, and, on that platform, gcc/g++ will be compiled to take advantage of them.

However, when the same pre-compiled gcc/g++ compiler is deployed with an older OS, your default system GNU linker ld will be older too, and there is a definite chance that the compatibility between gcc/g++ and ld will be broken. I know it did when I installed the pre-compiled gcc/g++ package from OpenFOAM 1.2 on my SuSE 9.1 workstation.

Some users also experienced the same kind of compatibility issues between gcc 4.1.0 and /usr/bin/ld on RedHat Enterprise AMD64 platforms.

In that situation, you have 3 options:

  1. You upgrade your Operating System to a newer version.
  2. You install a newer version of ld from GNU binutils for your spanking new gcc/g++ precompiled compiler.
  3. You recompile gcc/g++ in order for the configure script to discover the runtime options available from your system linker ld.


The rest of this section will describe options #2 and #3.

Other reasons would be: (NB: these 2 lines should go in a section like "Motivation for recompiling OpenFOAM")

  • You're developing a new utility or are looking for a bug in OpenFOAM: in that case you may want to have a version of OpenFOAM with debugging enabled
  • You don't have enough memory and precision isn't your primary concern. In that case you want to compile a single-precision version of OpenFOAM.

2.2 Selecting the right package to download

You should always download a GNU gcc/g++ source package with at least the same version, if not newer, as the version of the pre-compiled gcc/g++ compiler provided by OpenCFD, for the version of OpenFOAM you plan to use. The GNU gcc/g++ compiler source package is downloadable from the GCC GNU Web site, or from one of it's numerous mirrors.

Here is an example for OpenFOAM 1.3:

 
# create a temporary working directory
mkdir -p $HOME/OpenFOAM/linux/tmp
cd $HOME/OpenFOAM/linux/tmp
 
# download using standard ftp
ftp ftp.gnu.org
cd /gnu/gcc/gcc-4.1.0/
bin
get gcc-4.1.0.tar.bz2
exit

If you decide or need to install a local version of binutils, you can get it from the GNU Web site or GNU ftp site as well:

 
cd $HOME/OpenFOAM/linux/tmp
 
# download the latest version of binutils using standard ftp
ftp ftp.gnu.org
cd /gnu/binutils
bin
get binutils-2.16.1.tar.bz2
exit

2.3 Configuration, compilation and full installation of GNU binutils (optional)

This subsection describes the full installation of GNU binutils under $HOME/OpenFOAM/linux. You should only do a full install of GNU binutils if you are experiencing or suspecting compatibility problems between gcc 4.1.0 and your system's default linker "/usr/bin/ld".

You should also follow these installation steps prior to recompiling gcc 4.1.0; that way, the recompilation process of gcc will have access to the latest version of the linker "ld".

 
# NB: this is a first draft; the final validated version will come real soon...
 
# extraction
cd $HOME/OpenFOAM/linux/tmp
bzcat binutils-2.16.1.tar.bz2 | tar -xvf - 
 
cd binutils-2.16.1 
 
# configuration for x86 platforms
./configure --prefix=$HOME/OpenFOAM/linux/binutils-2.16.1 
 
# configuration for x86_64 platforms
./configure --prefix=$HOME/OpenFOAM/linuxAMD64/binutils-2.16.1
 
# compilation
make
 
#installation
make install
 
# installation for the binutils header files for x86 platforms
# for more information, see the section about the partial installation of binutils
make target_header_dir=$HOME/OpenFOAM/linux/binutils-2.16.1/include -C libiberty install_to_libdir
 
# installation for the binutils header files for x86_64 platforms
make target_header_dir=$HOME/OpenFOAM/linuxAMD64/binutils-2.16.1/include -C libiberty install_to_libdir
 
#cleanup
cd ..
rm -rf binutils-2.16.1
 
# Update your path (for bash)
export PATH=$HOME/OpenFOAM/linuxAMD64/binutils-2.16.1/bin:$PATH
 
# Update your path (for csh)
setenv PATH $HOME/OpenFOAM/linuxAMD64/binutils-2.16.1/bin:$PATH
 
# Final validation
# Should point to $HOME/OpenFOAM/linux/binutils-2.16.1/bin, or the AMD64 variant
which ld
 


Finally, make sure the configuration steps described further down in the section documenting the partial installation of binutils are followed as well. Those steps are important in order to compile the new, automatic stack trace on code abort capabilities of OpenFOAM 1.3.

2.4 Configuration, compilation and installation of GNU gcc

 
# extraction
cd $HOME/OpenFOAM/linux/tmp
 
bzcat gcc-4.1.0.tar.bz2 | tar -xvf - 
mkdir gcc-4.1.0/gcc-4.1.0-obj
cd gcc-4.1.0/gcc-4.1.0-obj 
 
# configuration for x86 platforms
../configure --prefix=$HOME/OpenFOAM/linux/gcc-4.1.0 --exec-prefix=$HOME/OpenFOAM/linux/gcc-4.1.0 \
    --enable-languages=c,c++ --enable-shared --disable-multilib
 
# configuration for x86_64 platforms
../configure --prefix=$HOME/OpenFOAM/linuxAMD64/gcc-4.1.0 --exec-prefix=$HOME/OpenFOAM/linuxAMD64/gcc-4.1.0 \
    --enable-languages=c,c++ --enable-shared --disable-multilib
 
# compilation
make bootstrap
 
#installation
make install
 
#cleanup
cd ../..
rm -rf gcc-4.1.0

3 Installing the Java JSDK

Nothing special to do here; simply download the default package from OpenCFD or SourceForge using your browser or a tool like wget, and install it under the right directory:

 
# download from a nearby SourceForge mirror
cd $HOME/OpenFOAM/linux/
wget http://umn.dl.sourceforge.net/sourceforge/foam/j2sdk1.4.2_05.linux.tgz
 
# extraction and installation
tar -zxvf j2sdk1.4.2_05.linux.tgz
 
# cleanup
rm j2sdk1.4.2_05.linux.tgz

4 Installing the OpenFOAM source code


4.1 Downloading and extracting the source code

It is now time to install the OpenFOAM source code, not because we are ready to compile it right away, but simply because we need to properly set some environment variables, and the OpenFOAM initialization scripts are exactly what is needed for such a job.

 
# download the OpenFOAM source code from OpenCFD or the closest SourceForge mirror
cd $HOME/OpenFOAM
wget http://umn.dl.sourceforge.net/sourceforge/foam/OpenFOAM-1.3.General.gtgz
 
# extract the source code
tar -zxvf OpenFOAM-1.3.General.gtgz

4.2 Modifying $HOME/OpenFOAM/OpenFOAM-1.3/.bashrc or $HOME/OpenFOAM/OpenFOAM-1.3/.cshrc (optional)

Next, we need to adjust some environment variables to reflect our compiler version if the version of gcc installed is newer than the default version available from OpenCFD.

This is specified in the file

$HOME/OpenFOAM/OpenFOAM-1.3/.bashrc or
$HOME/OpenFOAM/OpenFOAM-1.3/.cshrc

For example, for the file $HOME/OpenFOAM/OpenFOAM-1.3/.bashrc, we need to adjust the following line

 
# replace gcc-4.1.0 by gcc-4.xx.yy for the version 4.xx.yy of gcc
export WM_COMPILER_DIR=$WM_PROJECT_INST_DIR/$WM_ARCH/gcc-4.1.0$WM_COMPILER_ARCH

For the file $HOME/OpenFOAM/OpenFOAM-1.3/.cshrc, we need to adjust the following line

 
# replace gcc-4.1.0 by gcc-4.xx.yy for the version 4.xx.yy of gcc
setenv WM_COMPILER_DIR $WM_PROJECT_INST_DIR/$WM_ARCH/gcc-4.1.0$WM_COMPILER_ARCH

4.3 Modifying $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc or $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/cshrc (optional)

Next, we need to specify if we want to compile and use OpenFOAM on a x86 or x86_64 system, or if we want our root directory for OpenFOAM under a different directory than $HOME/OpenFOAM.

For this, we need to modify the file

$HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc or
$HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/cshrc

For example, for the file $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc, we may want to adjust or add the following lines

 
# uncomment the following line on a AMD64 workstation 
#export WM_64=1
 
# uncomment the following line if your OpenFOAM root directory in under /opt	
#export WM_PROJECT_INST_DIR=/opt/$WM_PROJECT

For the file $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/cshrc, we may want to adjust or add the following lines

 
# uncomment the following line on a AMD64 workstation 
#setenv WM_64 1
 
# uncomment the following line if your OpenFOAM root directory in under /opt	
#setenv WM_PROJECT_INST_DIR /opt/$WM_PROJECT

4.3.1 Modifications for a Single-Precision version of OpenFOAM

This works only for versions after 1.3

If you want a single-precision version of OpenFOAM (instead of the usual double-precision) change the lines in $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc from

 
# export WM_PRECISION_OPTION=SP
export WM_PRECISION_OPTION=DP

to

 
export WM_PRECISION_OPTION=SP
# export WM_PRECISION_OPTION=DP

4.3.2 Modifications for a debug version of OpenFOAM

If you want a debug version of OpenFOAM (which is slower but does range checking on containers etc) change the lines in $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc from

 
export WM_COMPILE_OPTION=Opt
# export WM_COMPILE_OPTION=Debug
# export WM_COMPILE_OPTION=Prof

to

 
# export WM_COMPILE_OPTION=Opt
export WM_COMPILE_OPTION=Debug
# export WM_COMPILE_OPTION=Prof

(if you want a profiling-enabled version of OpenFOAM uncomment the third line)

4.4 Initializing the OpenFOAM environment variables

We can now initialize all the required environment variables and aliases for properly compiling and running OpenFOAM.

If your current shell is bash

 
. $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc

If your current shell is csh or a csh look-alike like tcsh

 
source $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/cshrc

5 Compiling and installing cmake


Cmake is a cross-platform, open-source make system.

You need cmake for compiling ParaView.

Even though cmake is not supplied by OpenCFD as a companion tool for OpenFOAM, I find it useful to install cmake under the $HOME/OpenFOAM/linux directory, close to ParaView.

Here is the procedure for downloading, compiling and installing cmake:

 
# download the latest cmake source package from Kitware's ftp site:
mkdir $HOME/OpenFOAM/linux/tmp
cd $HOME/OpenFOAM/linux/tmp
 
ftp public.kitware.com
cd pub/cmake/v2.3
bin
get cmake-2.3.4-20060317.tar.gz
 
# extract the source code
tar -zxvf ./cmake-2.3.4-20060317.tar.gz
 
# configure cmake
cd cmake-2.3.4-20060317
./configure --prefix=$HOME/OpenFOAM/linux/cmake-2.3.4
make
make install
 
# cleanup
cd ../..
rm -rf ./tmp

Next, you need to modify the file $HOME/OpenFOAM/OpenFOAM-1.3/.bashrc or $HOME/OpenFOAM/OpenFOAM-1.3/.cshrc in order to add cmake to your $PATH environment variable. I usually insert those modifications at the end of the files.

Here is how to modify the file $HOME/OpenFOAM/OpenFOAM-1.3/.bashrc.

 
#
# cmake
#
# Make sure cmake is accessible
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export CMAKE=cmake-2.3.4
export CMAKE_ARCH_PATH=$WM_PROJECT_INST_DIR/$WM_ARCH/$CMAKE
AddPath $CMAKE_ARCH_PATH/bin

Here is how to modify the file $HOME/OpenFOAM/OpenFOAM-1.3/.cshrc.

 
#
# cmake
#
# Make sure cmake is accessible
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
setenv CMAKE cmake-2.3.4
setenv CMAKE_ARCH_PATH $WM_PROJECT_INST_DIR/$WM_ARCH/$CMAKE
AddPath $CMAKE_ARCH_PATH/bin

And of course, don't forget to reinitialize your environment:

If your current shell is bash

 
. $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc

If your current shell is csh or a csh look-alike like tcsh

 
source $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/cshrc

6 Compiling and installing ParaView


ParaView is probably the trickiest package to recompile. Here is how.

6.1 Selecting the right version of ParaView

You first need to download the source code from Kitware's Web site.

But before doing so, please note the version number of the binary ParaView package provided by OpenCFD. You need to download the ParaView source package with the same version number, or very close to it if you like living on the bleeding edge. Otherwise, if your version is too different, you risk not being able to link in the modules needed for paraFoam.

For example, for OpenFOAM 1.3, OpenCFD ParaView binary package version is paraview-2.4.2; you should then download the same version for the source package from Kitware's Web site.

Note however that ParaView latest stable version is 2.4.3; since the version number is very close to 2.4.2, I have chosen to use this version instead.

6.2 Downloading and installing ParaView source code

 
cd $HOME/OpenFOAM/linux
wget http://www.paraview.org/files/v2.4/paraview-2.4.3.tar.gz
 
tar -zxvf ./paraview-2.4.3.tar.gz
mkdir -p paraview-2.4.3/lib/paraview-2.4


If you decide to install a newer version of ParaView, you need to adjust the files
$HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/apps/paraview/bashrc
and
$HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/apps/paraview/cshrc

For $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/apps/paraview/bashrc, you need to modify this line

 
#export ParaView_VERSION=2.4.2
export ParaView_VERSION=2.4.3

For $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/apps/paraview/cshrc, you need to modify this line

 
#setenv ParaView_VERSION 2.4.2
setenv ParaView_VERSION 2.4.3

6.3 Patching Tcl/TK (optional)

Valid versions: OF version 13.png


Next, you may need to correct a bug that is not yet corrected in the companion Tcl/Tk source package that comes with ParaView.

That bug is documented on the Tcl/Tk mailing list, and is only affecting systems running bash version 3.1 or later. I have stumbled on that bug when compiling OpenFOAM 1.3 under Knoppix 5.0.

For more information, please check out the following link

The correction is rather simple, there are two typos in the files paraview-2.4.3/Utilities/TclTk/tcl8.4.5/unix/tcl.m4 and paraview-2.4.3/Utilities/TclTk/tk8.4.5/unix/tcl.m4.

Here is the first correction (the old code is commented out):

 
# starting on line 776 for both files:
 
# Bug fix: Remove the extra single quote close to .relid
#	    if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
#		system=MP-RAS-`awk '{print $3}' /etc/.relid'`
#	    fi
 
	    if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
		system=MP-RAS-`awk '{print $3}' /etc/.relid`
	    fi
 

The second correction is identical, only the line numbers are different:

 
# starting on line 2107 for the file paraview-2.4.3/Utilities/TclTk/tk8.4.5/unix/tcl.m4:
# starting on line 2117 for the file paraview-2.4.3/Utilities/TclTk/tcl8.4.5/unix/tcl.m4:
 
# Bug fix: Remove the extra single quote close to .relid
#	    if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
#		system=MP-RAS-`awk '{print $3}' /etc/.relid'`
#	    fi
 
	    if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
		system=MP-RAS-`awk '{print $3}' /etc/.relid`
	    fi
 


Next, you need to regenerate the Automake files. The command autoreconf is part of the Automake package. You need this package for recompiling ParaView.

 
cd $HOME/OpenFOAM/linux/paraview-2.4.3/Utilities/TclTk/tcl8.4.5/unix
autoreconf
 
cd $HOME/OpenFOAM/linux/paraview-2.4.3/Utilities/TclTk/tk8.4.5/unix
 
#This invocation of autoreconf will end with some error message about AC_LIBOBJ. 
#You can ignore this error message.
autoreconf

6.4 Modification to the file CMakeLists.txt

Before you do this, make sure you'v installed the develep package of tcl, tk, xorg/xfree. Next, we need to modify the file $HOME/OpenFOAM/linux/paraview-2.4.3/CMakeLists.txt in order to force the installation of the ParaView header files when we will invoke the command make install a little bit later.

Here are the lines we need to modify; watch for the comments starting with OpenFOAM::

 
# Setup install directories.
IF(NOT PV_INSTALL_BIN_DIR)
  SET(PV_INSTALL_BIN_DIR ${PV_INSTALL_ROOT}/bin)
ENDIF(NOT PV_INSTALL_BIN_DIR)
IF(NOT PV_INSTALL_INCLUDE_DIR)
#
# OpenFOAM: we need to modify this line
#  SET(PV_INSTALL_INCLUDE_DIR ${PV_INSTALL_ROOT}/include/paraview-${PARAVIEW_VERSION})
  SET(PV_INSTALL_INCLUDE_DIR ${PV_INSTALL_ROOT}/include)
#
# OpenFOAM: end of modification
#
ENDIF(NOT PV_INSTALL_INCLUDE_DIR)
IF(NOT PV_INSTALL_LIB_DIR)
  SET(PV_INSTALL_LIB_DIR ${PV_INSTALL_ROOT}/lib/paraview-${PARAVIEW_VERSION})
ENDIF(NOT PV_INSTALL_LIB_DIR)
IF(NOT PV_INSTALL_DATA_DIR)
  SET(PV_INSTALL_DATA_DIR ${PV_INSTALL_ROOT}/share/paraview-${PARAVIEW_VERSION})
ENDIF(NOT PV_INSTALL_DATA_DIR)
 
# Install no development files by default, but allow the user to get
# them installed by setting PV_INSTALL_DEVELOPMENT to true.  Disable
# the option altogether if PV_INSTALL_NO_DEVELOPMENT is already set to
# true.
#
# OpenFOAM: we need to add this line.
#
SET(PV_INSTALL_DEVELOPMENT 1)
#
# OpenFOAM: end of modification
#
IF(NOT PV_INSTALL_NO_DEVELOPMENT)
  # Leave this option out until we write code to install paraview headers
  # other than VTK.
  #OPTION(PV_INSTALL_DEVELOPMENT "Install ParaView plugin development files."
  #  OFF)
  #MARK_AS_ADVANCED(PV_INSTALL_DEVELOPMENT)

6.5 Initial configuration using cmake

Next, we use the default invocation of cmake to get the initial configuration of Paraview

 
cd $HOME/OpenFOAM/linux/paraview-2.4.3/lib/paraview-2.4
cmake ../..

6.6 Adjusting the configuration

Next, we need to adjust the initial ParaView configuration in order to get the proper settings for compiling with OpenFOAM.

For this, you need to edit the file $HOME/OpenFOAM/linux/paraview-2.4.3/lib/paraview-2.4/CMakeCache.txt using your favourite text editor. That file was automagically created by the prior invocation of cmake.

Here are the lines and configuration variables that need to be modified. The default values previously generated by cmake are commented out.

 
# BUILD_SHARED_LIBS:BOOL=OFF
BUILD_SHARED_LIBS:BOOL=ON
 
# BUILD_TESTING:BOOL=ON
BUILD_TESTING:BOOL=OFF
 
# CMAKE_INSTALL_PREFIX:PATH=/usr/local
CMAKE_INSTALL_PREFIX:PATH=/home/whatever_your_login_is/OpenFOAM/linux/paraview-2.4.3
 

For compiling ParaView for x86_64, we need to modify some other configuration variables. Here are the variables I had to modify for SuSE 9.1 x86_64. Adjust accordingly to your own specific 64-bit Operating System.

 
BUILD_SHARED_LIBS: ON
CMAKE_BUILD_TYPE : 
CMAKE_CXX_COMPILER : /home/your_login_name/OpenFOAM/linuxAMD64/gcc-4.1.0/bin/g++
CMAKE_CXX_FLAGS : -m64
CMAKE_C_COMPILER : /home/your_login_name/OpenFOAM/linuxAMD64/gcc-4.1.0/bin/gcc
CMAKE_C_FLAGS : -m64
CMAKE_EXE_LINKER_FLAGS : -m64
CMAKE_EXE_LINKER_FLAGS_RELEASE : -m64
CCMAKE_MODULE_LINKER_FLAGS : -m64
CMAKE_INSTALL_PREFIX : /home/your_login_name/OpenFOAM/linuxAMD64/paraview-2.4.3
CMAKE_MODULE_LINKER_FLAGS : -m64
CMAKE_MODULE_LINKER_FLAGS_RELEASE : -m64
CMAKE_SHARED_LINKER_FLAGS : -m64
CMAKE_SHARED_LINKER_FLAGS_RELEASE : -m64
OPENGL_gl_LIBRARY : /usr/lib64/libGL.so
OPENGL_glu_LIBRARY: /usr/X11R6/lib64/libGLU.a
X11_X11_LIB : /usr/X11R6/lib64/libX11.so
X11_Xext_LIB : /usr/X11R6/lib64/libXext.so 
CMAKE_X_LIBS : /usr/X11R6/lib64/libX11.so;/usr/X11R6/lib64/libXext.so;/usr/X11R6/lib64/libX11.so;/usr/X11R6/lib64/libXext.so
X11_Xext_LIB: /usr/X11R6/lib64/libXext.so

I used OpenSUSE 10.1 x86_64 with Tcl/Tk-8.4.5, I found that if you want to compile paraview-2.4.3, you need to add the following parameters to CMakeCache.txt

 
TCL_LIBRARY:FILEPATH=/usr/lib64/tcl8.4.so
TK_LIBRARY:FILEPATH=/usr/lib64/tk8.4.so

Note: my recompiled 64 bit version of paraView 2.4.3 is crashing under SuSE 9.1. I had no such problem with paraview 2.2.1 (OpenFOAM 1.2). As soon as I find the source of the problem, I will document it here...

6.7 Compiling and installing paraview

At last, the moment of truth :)

 
cd $HOME/OpenFOAM/linux/paraview-2.4.3/lib/paraview-2.4
make
make install

7 Modifications for the compilation of PVFoamReader


Valid versions: OF version 13.png

In order to compile the module $HOME/OpenFOAM/OpenFOAM-1.3/applications/utilities/postProcessing/graphics/PVFoamReader,

we need to modify the file $HOME/OpenFOAM/OpenFOAM-1.3/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/CMakeLists.txt

for two reasons:

  1. The position of the LINK_DIRECTORIES instruction in the file is important, and using a recent version of cmake (cmake-2.3.4-20060317), the linker search path specified in the Makefile will not be written correctly without the modifications.
  2. You must include the directory $FOAM_USER_LIBBIN in the linker search path if you want the module PVFoamReader (and paraFoam) to use your local ${FOAM_USER_LIBBIN}/libfoamUser.so library (for your user-defined boundary condition code, etc,).

Otherwise,

  1. Your library libPVFoamReader.so will fail to link against libOpenFOAM.so because it cannot find it.
  2. paraFoam will fail to load your user-defined code because the library libPVFoamReader.so will be link against the default library ${FOAM_LIBBIN}/libfoamUser.so instead of your local version ${FOAM_USER_LIBBIN}/libfoamUser.so.

Here is the modifications needed for the file $HOME/OpenFOAM/OpenFOAM-1.3/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/CMakeLists.txt .

We only show a part of that file; look for the instructions preceded by a comment mentionning cmake version 2.3.4-20060317

 
# Create the configuration header.
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/PVFoamReaderConfigure.h.in
               ${PROJECT_BINARY_DIR}/vtk${PROJECT_NAME}Configure.h
               @ONLY IMMEDIATE)
 
# Create vtk client/server wrappers for the classes.
VTK_WRAP_ClientServer(${PROJECT_NAME} PVFoamReaderCS_SRCS "${PVFoamReader_SRCS}")
 
# Must be defined before ADD_LIBRARY  for cmake version 2.3.4-20060317
LINK_DIRECTORIES($ENV{FOAM_USER_LIBBIN})
LINK_DIRECTORIES($ENV{FOAM_LIBBIN})
 
# Build the package as a plugin for ParaView.
ADD_LIBRARY(${PROJECT_NAME} MODULE ${PVFoamReader_SRCS} ${PVFoamReaderCS_SRCS})
LINK_DIRECTORIES($ENV{ParaView_INST_DIR}/lib)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} vtkClientServer)
FOREACH(c ${PVFoamReader_LIBS})
  TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${c}CS)
ENDFOREACH(c)
 
# Place the package configuration file into the build tree.
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/PVFoamReader.xml.in
               ${PROJECT_BINARY_DIR}/../${PROJECT_NAME}.xml @ONLY IMMEDIATE)
 
# Place the package configuration file into the build tree.
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/PVFoamReader.pvsm.in
               ${PROJECT_BINARY_DIR}/../${PROJECT_NAME}.pvsm @ONLY IMMEDIATE)
 
# Must be commented out for cmake version 2.3.4-20060317
#LINK_DIRECTORIES($ENV{FOAM_LIBBIN})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} OpenFOAM finiteVolume vtkFoam)
 


Once this modification made, the normal OpenFOAM 1.3 compilation scripts will take care of the rest.


8 Partial installation of GNU binutils (optional)


With OpenFOAM 1.3, OpenCFD introduces a new, automatic stack trace on code abort. This new capability is based on the library libiberty from the package GNU binutils. That library comes standard with most Linux-based OS. However, in order to recompile OpenFOAM, you also need to have a valid header file called /usr/include/demangle.h, also provided by GNU binutils.

That header file is present on SuSE OS, but not on RedHat/Fedora nor on Knoppix/Debian systems.

Looking at the scripts designed to construct the installation RPM of the binary package GNU binutils, we can see that SuSE took an extra installation step in order to install under the directory /usr/include a few more header files from the GNU binutils package, including the demangle.h file.

This section gives a quick description on how to install the missing header files locally under the directory $HOME/OpenFOAM/linux.

You first need to identify the version of GNU binutils installed on your system. For instance, on a RedHat WS 4, you can get that information like this:

 
% rpm -qa | grep -i binutils
binutils-2.15.92.0.2-15

Given that basic information, here the installation procedure:

 
# First, create a temporary directory for extracting the GNU binutils source code
mkdir -p $HOME/OpenFOAM/linux/binutils-2.15/src
cd $HOME/OpenFOAM/linux/binutils-2.15/src
 
# Next, download the proper version on the GNU binutils source code
 
# Download from the Web site
wget http://ftp.gnu.org/gnu/binutils/binutils-2.15.tar.gz
tar -zxvf binutils-2.15.tar.gz
cd binutils-2.15
 
# Or Download using CVS
cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src login
  {enter "anoncvs" as the password}
 
cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src co -r binutils-2_15 binutils
cd src
 
# Next, proceed with the configuration of the package
./configure --prefix=$HOME/OpenFOAM/linux/binutils-2.15
 
# Next, execute a partial installation in order to get the missing header files
make
make target_header_dir=$HOME/OpenFOAM/linux/binutils-2.15/include -C libiberty install_to_libdir
 
# Finally, let's clean up
rm -rf $HOME/OpenFOAM/linux/binutils-2.15/src

8.1 Configuring OpenFOAM

NB: If you already did a full installation of binutils, please make sure all the steps describe in that subsection are realized as well, but for binutils-2.16.1.

We now have the needed header files installed locally under the directory $HOME/OpenFOAM/linux/binutils-2.15/include

We must now tell OpenFOAM where to find these new header files:

First, we create the new environment variable _BINUTILS_FOR_DEMANGLE_H.

Warning: Please make sure not to redefine the environment variable called BINUTILS_ROOT. This environment variable is a reserved variable for the compilation tools like the first stage compiler cc1 from the gcc compiler. This redefinition will break the linker ld as well. An obvious symptom of such a redefinition of this variable will be the appearance of the error message

 
/usr/bin/ld: crtbegin.o: No such file: No such file or directory

when trying to link a simple executable program.


We will define this new variable _BINUTILS_FOR_DEMANGLE_H in the files $HOME/OpenFOAM/OpenFOAM-1.3/.bashrc and/or $HOME/OpenFOAM/OpenFOAM-1.3/.cshrc.

Here is how to modify $HOME/OpenFOAM/OpenFOAM-1.3/.bashrc

 
# Binutils header files
# Under Redhat, some header files like demangle.h are missing
#
# For now, we are using a local and partial installation of binutils in order 
# to provides only the missing header files. 
# The libraries are already provided by default by the OS (RedHat, SuSE, Knoppix, etc).
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#export _BINUTILS_FOR_DEMANGLE_H=/usr
export _BINUTILS_FOR_DEMANGLE_H=$WM_PROJECT_INST_DIR/$WM_ARCH/binutils-2.15
 
# If you installed binutils-2.16.1 instead:
export _BINUTILS_FOR_DEMANGLE_H=$WM_PROJECT_INST_DIR/$WM_ARCH/binutils-2.16.1
 
 

Then, we modify the file $HOME/OpenFOAM/OpenFOAM-1.3/src/OpenFOAM/Make/options for the compilation of the library libOpenFOAM:

 
EXE_INC = \
    -DWM_PROJECT_VERSION='"'$(WM_PROJECT_VERSION)'"' \
    -I$(_BINUTILS_FOR_DEMANGLE_H)/include/ \
    -I$(LIB_SRC)/zlib-1.2.1
 
LIB_LIBS = -L$(FOAM_LIBBIN)/dummy -lPstream -lfoamUser -lz

The library libOpenFOAM, and the rest of OpenFOAM 1.3 should now compile without a glitch with the new, automatic stack trace on code abort capabilities up and ready.

9 Miscellaneous adjustments (optional)


Some OpenFOAM compilation script files either use gmake, or make.

Under Knoppix 5.0, gmake is absent, but make do exist.

To correct this problem, we simply need to create a symbolic link under /usr/local/bin.

 
# Become root
su
 
#Create the symlink
ln -s `which make` /usr/local/bin/gmake

Of course, the directory /usr/local/bin needs to be in your path, so take the time to verify and to adjust your path if necessary.

 
% echo $PATH
 
# if /usr/local/bin/ is not in your PATH environment variable, simply do: (for example under bash)
 
% export PATH=/usr/local/bin:$PATH
 
# and/or adjust your $HOME/.bashrc accordingly.
 

10 Compiling OpenFOAM

Now the easy stuff...

 
cd $HOME/OpenFOAM/OpenFOAM-1.3
./Allwmake


Cheers!


Valid versions: OF version 14.png

--MB 05:16, 10 Apr 2006 (CEST)