Installation/Outdated/Howto compile OpenFOAM
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 document is now in a pretty stable state because many people went over it since the initial version was published. There is always room for improvement, of course, but before you do modify this text, please hesitate for 5 minutes, just to be sure that the new information you will add is really useful for the community, necessary and proven to be true.
Contents
- 1 Preamble
- 2 Compiling and installing GNU Gcc
- 3 Installing the Java JSDK
- 4 Installing the OpenFOAM source code
- 4.1 Downloading and extracting the source code
- 4.2 Modifying $HOME/OpenFOAM/OpenFOAM-1.3/.bashrc or $HOME/OpenFOAM/OpenFOAM-1.3/.cshrc (optional)
- 4.3 Modifying $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc or $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/cshrc (optional)
- 4.4 Initializing the OpenFOAM environment variables
- 5 Compiling and installing cmake
- 6 Compiling and installing ParaView
- 7 Modifications for the compilation of PVFoamReader
- 8 Partial installation of GNU binutils (optional)
- 9 Miscellaneous adjustments (optional)
- 10 Compiling OpenFOAM
- 11 Building OpenFOAM on OpenSolaris x86_32 2/07
- 12 Building on x86_64 Fedora Core (AMD64) and Gentoo (EMT64)
- 12.1 Compiling 1.4.1 from source on x86_64
- 12.2 Use of subversion
- 12.3 Compilation problems
- 12.3.1 Readline libraries on some x86_64
- 12.3.2 Java tools missing
- 12.3.3 Cannot find interpolatePointToCell.H while compiling foamToVTK.C
- 12.3.4 error while loading shared libraries: /usr/lib64/libz.so: invalid ELF header
- 12.3.5 /usr/bin/ld: cannot find -lfiniteVolume
- 12.3.6 FoamXHostBrowser: not found
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 in the download page.
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:
- You upgrade your Operating System to a newer version.
- You install a newer version of ld from GNU binutils for your spanking new gcc/g++ precompiled compiler.
- 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".
# 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
The development version can be downloaded from http://openfoam-extend.svn.sourceforge.net with the command
svn co https://svn.code.sf.net/p/openfoam-extend/svn/trunk/Core/OpenFOAM-1.4.1-dev
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.
Note: OpenFOAM 1.4 and 1.4.1 use ParaView-2.4.4 . And as of Sep 6 2007 the latest stable version is 3.0.2.
Note: OpenFoam 1.5 uses ParaView3.3
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)
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.
With version 1.4 of OpenFOAM and version 2.6.1 of Paraview, the file that we need to modify lies now in $HOME/OpenFOAM/linux/paraview-2.6.1/CMake/ParaViewCommon.cmake. The modifications are the same.
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
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:
- 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.
- 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,
- Your library libPVFoamReader.so will fail to link against libOpenFOAM.so because it cannot find it.
- 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 for using binutils demangle.h
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 # If you did a full install for binutils, why not use the binary tools as well... AddPath $_BINUTILS_FOR_DEMANGLE_H/bin
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 does 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
Note: If you compile the development version, it has been reported that Allwmake might have to be called twice. This will be investigated and some corrections, if any, will be proposed.
Cheers!
11 Building OpenFOAM on OpenSolaris x86_32 2/07
Configure GCC as follows:
../configure --prefix=$HOME/OpenFOAM/linux/gcc-4.2.0 --exec-prefix=$HOME/OpenFOAM/linux/gcc-4.2.0 \ --with-ld=/usr/ccs/bin/ld --without-gnu-ld \ --enable-languages=c,c++ --enable-shared --disable-multilib
After that compile and install as described above.
You also need to download from http://flex.sourceforge.net/ and install the newest version of flex
to use it instead of default for OpenSolaris v.2.5.4.
After installation add to local .bashrc
the followings:
export PATH=PATH_TO_YOUR_NEW_FLEX_BIN:$PATH alias flex++='flex -+'
Now configure and compile OpenFOAM as described above.
Due to the fact that command find
on OpenSolaris does not support the option -maxdepth
, the building the applications in $WM_PROJECT_DIR/applications
will fail.
To complete the building, create and execute the following script:
#!/usr/bin/perl use File::Find; chdir "$ENV{'WM_PROJECT_DIR'}/applications"; find(\&MakeIt, "./"); sub MakeIt { -f and return; if (-d "$_/Make") { print "Building $File::Find::name ...\n"; $File::Find::prune = 1; system "wmake $_"; } }
--MB 02:44, 13 Apr 2007 (CEST)
12 Building on x86_64 Fedora Core (AMD64) and Gentoo (EMT64)
According to OpenCFD "We strongly recommend that OpenFOAM is installed in a user account to make administration easier," that is, in $HOME. Mattijs Janssens admits "Keeping the package within $HOME is personal preference. At our place it is the only area that is nfs mounted everywhere." The recommendation is non-standard and administration on a multiuser system can be improved if a single installation is used, in say /usr/local/ or /opt. A single installation is less wasteful of memory and gives all users access to the latest version, where any installation problems need only be addressed once. Optional downloads for OpenFOAM include gcc, java and paraview. It can also make sense to decouple the installation and upgrade process of these more general packages from OpenFOAM.
12.1 Compiling 1.4.1 from source on x86_64
We want to use an existing installation of gcc and paraview. In this example we do not wish to use the FoamX gui, which uses java. The gui can help the transition for new users, but can be more trouble than its worth and if you want to become proficient in OpenFOAM, you'll get a lot more value out of the command line. We will install in /usr/local/OpenFOAM, and so must be logged in as root user. We assume that bash is our shell program. First, obtain the source tarball:
[root@prandtl /]# cd /usr/local [root@prandtl /usr/local]# mkdir OpenFOAM [root@prandtl /usr/local]# cd OpenFOAM [root@prandtl /usr/local/OpenFOAM]# wget http://downloads.sourceforge.net/foam/OpenFOAM-1.4.1.General.gtgz?use_mirror=mesh [root@prandtl /usr/local/OpenFOAM]# tar xvzf OpenFOAM-1.4.1.General.gtgz
This will create a directory OpenFOAM-1.4.1. Create
[root@prandtl /usr/local/OpenFOAM]# mkdir linux64
Find out what version of gcc you have, and where it is
[root@prandtl /usr/local/OpenFOAM]# gcc -dumpversion 4.1.0 [root@prandtl /usr/local/OpenFOAM]]# which gcc /usr/bin/gcc
It is recommended to use gcc 4.1.0 or higher for OpenFOAM 1.4.1. Typically, lower compiler versions will (mostly) work, but the risk of problems increases the lower the version. Now go to /usr/local/OpenFOAM/OpenFOAM-1.4.1 and open .OpenFOAM-1.4.1/bashrc for editing. Add the following line near the top of the script:
export WM_64='hello ladies!'
the value of WM_64 is not important, just the fact that it is defined (WM refers to "wmake", the wrapper script for the GNU utility make that does all the compiling). Next, comment out
#export WM_PROJECT_INST_DIR=$HOME/$WM_PROJECT
and uncomment
export WM_PROJECT_INST_DIR=/usr/local/$WM_PROJECT
We want to use the existing gcc, so change the line
export WM_COMPILER=Gcc
to
export WM_COMPILER=
In 1.4.1 there is a minor bug that requires you to create this symbolic link,
[root@prandtl /usr/local/OpenFOAM/OpenFOAM-1.4.1]# ln -s wmake/rules/linux64Gcc wmake/rules/linux64
Now we will set the compiler flags for the x86_64 case. The default flags are
export CFLAGS='-m64 -fPIC' export CXXFLAGS='-m64 -fPIC' export LDFLAGS='-m64'
The way OpenFOAM is organised, since we will add this bashrc file to each user shell initialisation path, this will also set your default flags used for compiling things generally on your system (of course this can be overridden within a shell but it is a pain). These flags are only really needed by a few packages within the OpenFOAM installation, some of which, such as mico, are only needed for the FoamX gui. Perhaps this configuration aspect will improve in the future, but for the moment you need to keep these flags only when building the whole installation. There is a whole body of thought on the best CFLAGS, for example in this case a better, safer choice once you have done the main package build is to comment out the flags above and add:
export CFLAGS="-march=k8 -O2 -pipe -fomit-frame-pointer" export CXXFLAGS=$CFLAGS export LDFLAGS=
on a non-EMT64 (Intel) machine, or for EMT64,
export CFLAGS="-march=nocona -O2 -pipe -fomit-frame-pointer" export CXXFLAGS=$CFLAGS export LDFLAGS=
We are done with this primary shell configuration script, so save and open usr/local/OpenFOAM/OpenFOAM-1.4.1/.bashrc for editing. Change the section
if [ "$WM_COMPILER" = "Gcc" -o "$machineTest" = "Linux" -a "$WM_COMPILER" = "" ]; then export WM_COMPILER_DIR=$WM_PROJECT_INST_DIR/$WM_ARCH/gcc-4.1.0$WM_COMPILER_ARCH WM_COMPILER_BIN="$WM_COMPILER_DIR/bin:$WM_COMPILER_DIR/../gdb-6.4/bin" WM_COMPILER_LIB=$WM_COMPILER_DIR/lib${WM_COMPILER_LIB_ARCH}:$WM_COMPILER_DIR/lib: fi
to
if [ "$WM_COMPILER" = "Gcc" -o "$machineTest" = "Linux" -a "$WM_COMPILER" = "" ]; then #export WM_COMPILER_DIR=$WM_PROJECT_INST_DIR/$WM_ARCH/gcc-4.1.2$WM_COMPILER_ARCH export WM_COMPILER_DIR=/usr WM_COMPILER_BIN="$WM_COMPILER_DIR/bin:$WM_COMPILER_DIR/../gdb-6.4/bin" WM_COMPILER_LIB=$WM_COMPILER_DIR/lib${WM_COMPILER_LIB_ARCH}:$WM_COMPILER_DIR/lib: fi
and although we are not using java/FoamX, for completeness, comment out
export JAVA_HOME=$WM_PROJECT_INST_DIR/$WM_ARCH/j2sdk1.4.2_05
and add
export JAVA_HOME=/usr
Save and exit. Since we'll use the existing shell to do the build, we need to load up all the enviornment variables from these configuration files,
[root@prandtl /usr/local/OpenFOAM/OpenFOAM-1.4.1]# source .OpenFOAM-1.4.1/bashrc
Each user will need to do this, and the most convenient way is to include it during shell initialisation by adding
source /usr/local/OpenFOAM/OpenFOAM-1.4.1/.OpenFOAM-1.4.1/bashrc
at the bottom of each $HOME/.bashrc. Of course this will need to be updated any time there is a version change. Finally, start the build:
[root@prandtl /usr/local/OpenFOAM/OpenFOAM-1.4.1]# ./Allwmake
This typically takes several hours. Test the installation by running
[root@prandtl /usr/local/OpenFOAM/OpenFOAM-1.4.1]# /bin/foamInstallationTest
and you can ignore any error about the root user bashrc not calling the OpenFOAM configuration script, if all usage will be via non-root user accounts (as it should be).
12.1.1 User shell configuration files
If each user had
source /usr/local/OpenFOAM/OpenFOAM-1.4.1/.OpenFOAM-1.4.1/bashrc
in their $HOME/.bashrc, this would need to be changed every time OpenFOAM was upgraded. Instead, replace this with
source /usr/local/OpenFOAM/bashrc
and create the symbolic link
[root@prandtl /usr/local/OpenFOAM]# ln -s .OpenFOAM-1.4.1/bashrc bashrc
This is the only thing that will need to be changed for each future upgrade.
12.1.2 Permissions
We inevitably run into the need to reset permissions because the default installation is intended for $HOME use. First, make everything in $WM_PROJECT_DIR readable by everyone and the group and everything writeable by the group
[root@prandtl /usr/local/OpenFOAM/OpenFOAM-1.4.1]# find -exec /bin/chmod go+r '{}' ';' [root@prandtl /usr/local/OpenFOAM/OpenFOAM-1.4.1]# find -exec /bin/chmod g+w '{}' ';'
then
[root@prandtl /usr/local/OpenFOAM/OpenFOAM-1.4.1]# chmod g+x bin/
The default group is root, we are going to create a group openfoam and each account that wishes to use it will need to be added to this new group.
[root@prandtl /usr/local/OpenFOAM/OpenFOAM-1.4.1]# groupadd openfoam [root@prandtl /usr/local/OpenFOAM/OpenFOAM-1.4.1]# usermod -G openfoam <user>
12.1.3 User account usage
Return to your user account and re-source your shell configuration script,
hoogland@prandtl ~ $ . ~/.bashrc Executing: /usr/local/OpenFOAM/OpenFOAM-1.4.1/.bashrc Executing: /usr/local/OpenFOAM/OpenFOAM-1.4.1/.OpenFOAM-1.4.1/apps/ensightFoam/bashrc Executing: /usr/local/OpenFOAM/OpenFOAM-1.4.1/.OpenFOAM-1.4.1/apps/paraview/bashrc
this will automatically create $HOME/OpenFOAM and your associated use directory $HOME/OpenFOAM/$USER-1.4.1 if it does not exist
hoogland@prandtl ~ $ cd OpenFOAM hoogland@prandtl ~ $ ls hoogland-1.4.1 applications lib
The version number is appended to the user directory because the latest base code may contain features incompatible with your own custom code. $WM_PROJECT_DIR/.OpenFOAM-1.4.1/bashrc defines some useful aliases:
alias src='cd $FOAM_SRC' alias lib='cd $FOAM_LIB' alias run='cd $FOAM_RUN' alias foam='cd $WM_PROJECT_DIR' alias foamsrc='cd $FOAM_SRC/$WM_PROJECT' alias foamfv='cd $FOAM_SRC/finiteVolume' alias app='cd $FOAM_APP' alias util='cd $FOAM_UTILITIES' alias sol='cd $FOAM_SOLVERS' alias tut='cd $FOAM_TUTORIALS'
and run, for example, now points to the newly created $HOME/OpenFOAM/hoogland-1.4.1/run. This directory is not automatically create it, so you need to do so,
hoogland@prandtl ~/OpenFOAM $ mkdir hoogland-1.4.1/run
12.2 Use of subversion
If you use a revision control system such as subversion (recommended), you can keep a single user directory location from one OpenFOAM version to the next. Suppose you have a user directory tree established in a local svn working copy, then simply replace the existing user directory with a symbolic link, for example,
hoogland@prandtl ~/OpenFOAM $ rm -fr hoogland-1.4.1 hoogland@prandtl ~/OpenFOAM $ ln -s ~/svn-MyRepo/trunk/src/openfoam hoogland-1.4.1
The main limitation currently with this approach is that you cannot instruct OpenFOAM to direct solution directories to a location other than the default case directory. Solution directories can become very large and it makes sense to keep this data out of the repository, which works best for archiving and logging text files.
- I supplemented this by copying the $WM_PROJECT_DIR/src/ and $WM_PROJECT_DIR/applications/ directories, containing most of the source you might want to modify, into an svn repository and replacing the original directory trees with symlinks to the relevant directories in the repo. Bit of an extra burden to change add these symlinks in future upgrades, but worth it for complete version archiving and logging. Hoogs 05:21, 22 Aug 2007 (CEST)
12.3 Compilation problems
12.3.1 Readline libraries on some x86_64
For x86_64, some systems need to be told about an extra library for readline. The error gives (on prandtl):
Found readline/readline.h include file. Enabling readline support. make[3]: Entering directory `/usr/local/OpenFOAM/OpenFOAM-1.4.1/applications/utilities/mesh/manipulation/Optional/setSet' make[3]: Leaving directory `/usr/local/OpenFOAM/OpenFOAM-1.4.1/applications/utilities/mesh/manipulation/Optional/setSet' make[3]: Entering directory `/usr/local/OpenFOAM/OpenFOAM-1.4.1/applications/utilities/mesh/manipulation/Optional/setSet' SOURCE=writePointSet.C ; g++ -m64 -Dlinux64 -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -march=opteron -O3 -DNoRepository -ftemplate-depth-40 -DREADLINE=1 -I/usr/local/OpenFOAM/OpenFOAM-1.4.1/src/meshTools/lnInclude -IlnInclude -I. -I/usr/local/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude -fPIC -c $SOURCE -o Make/linux64DPOpt/writePointSet.o SOURCE=floatScalar.C ; g++ -m64 -Dlinux64 -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -march=opteron -O3 -DNoRepository -ftemplate-depth-40 -DREADLINE=1 -I/usr/local/OpenFOAM/OpenFOAM-1.4.1/src/meshTools/lnInclude -IlnInclude -I. -I/usr/local/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude -fPIC -c $SOURCE -o Make/linux64DPOpt/floatScalar.o SOURCE=writeFuns.C ; g++ -m64 -Dlinux64 -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -march=opteron -O3 -DNoRepository -ftemplate-depth-40 -DREADLINE=1 -I/usr/local/OpenFOAM/OpenFOAM-1.4.1/src/meshTools/lnInclude -IlnInclude -I. -I/usr/local/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude -fPIC -c $SOURCE -o Make/linux64DPOpt/writeFuns.o SOURCE=writePatch.C ; g++ -m64 -Dlinux64 -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -march=opteron -O3 -DNoRepository -ftemplate-depth-40 -DREADLINE=1 -I/usr/local/OpenFOAM/OpenFOAM-1.4.1/src/meshTools/lnInclude -IlnInclude -I. -I/usr/local/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude -fPIC -c $SOURCE -o Make/linux64DPOpt/writePatch.o SOURCE=fieldToCell.C ; g++ -m64 -Dlinux64 -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -march=opteron -O3 -DNoRepository -ftemplate-depth-40 -DREADLINE=1 -I/usr/local/OpenFOAM/OpenFOAM-1.4.1/src/meshTools/lnInclude -IlnInclude -I. -I/usr/local/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude -fPIC -c $SOURCE -o Make/linux64DPOpt/fieldToCell.o SOURCE=setSet.C ; g++ -m64 -Dlinux64 -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -march=opteron -O3 -DNoRepository -ftemplate-depth-40 -DREADLINE=1 -I/usr/local/OpenFOAM/OpenFOAM-1.4.1/src/meshTools/lnInclude -IlnInclude -I. -I/usr/local/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude -fPIC -c $SOURCE -o Make/linux64DPOpt/setSet.o g++ -m64 -Dlinux64 -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -march=opteron -O3 -DNoRepository -ftemplate-depth-40 -DREADLINE=1 -I/usr/local/OpenFOAM/OpenFOAM-1.4.1/src/meshTools/lnInclude -IlnInclude -I. -I/usr/local/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude -fPIC Make/linux64DPOpt/writePointSet.o Make/linux64DPOpt/floatScalar.o Make/linux64DPOpt/writeFuns.o Make/linux64DPOpt/writePatch.o Make/linux64DPOpt/fieldToCell.o Make/linux64DPOpt/setSet.o -L/usr/local/OpenFOAM/OpenFOAM-1.4.1/lib/linux64DPOpt \ -lmeshTools -lreadline -lOpenFOAM -liberty -ldl -lm -o /usr/local/OpenFOAM/OpenFOAM-1.4.1/applications/bin/linux64DPOpt/setSet /usr/lib/gcc/x86_64-redhat-linux/4.1.0/../../../../lib64/libreadline.so: undefined reference to `tgetnum' /usr/lib/gcc/x86_64-redhat-linux/4.1.0/../../../../lib64/libreadline.so: undefined reference to `tgoto' /usr/lib/gcc/x86_64-redhat-linux/4.1.0/../../../../lib64/libreadline.so: undefined reference to `tgetflag' /usr/lib/gcc/x86_64-redhat-linux/4.1.0/../../../../lib64/libreadline.so: undefined reference to `BC' /usr/lib/gcc/x86_64-redhat-linux/4.1.0/../../../../lib64/libreadline.so: undefined reference to `tputs' /usr/lib/gcc/x86_64-redhat-linux/4.1.0/../../../../lib64/libreadline.so: undefined reference to `PC' /usr/lib/gcc/x86_64-redhat-linux/4.1.0/../../../../lib64/libreadline.so: undefined reference to `tgetent' /usr/lib/gcc/x86_64-redhat-linux/4.1.0/../../../../lib64/libreadline.so: undefined reference to `UP' /usr/lib/gcc/x86_64-redhat-linux/4.1.0/../../../../lib64/libreadline.so: undefined reference to `tgetstr' collect2: ld returned 1 exit status make[3]: *** [/usr/local/OpenFOAM/OpenFOAM-1.4.1/applications/bin/linux64DPOpt/setSet] Error 1 make[3]: Leaving directory `/usr/local/OpenFOAM/OpenFOAM-1.4.1/applications/utilities/mesh/manipulation/Optional/setSet' make[2]: *** [Optional] Error 2 make[2]: Leaving directory `/usr/local/OpenFOAM/OpenFOAM-1.4.1/applications/utilities/mesh/manipulation' make[1]: *** [manipulation] Error 2 make[1]: Leaving directory `/usr/local/OpenFOAM/OpenFOAM-1.4.1/applications/utilities/mesh' make: *** [mesh] Error 2 + '[' 0 = 1 -a '' = doc ']'
to fix, change $WM_PROJECT_DIR/applications/utilities/mesh/manipulation/Optional/Allwmake from
#!/bin/sh READLINE=0 if [ -f /usr/include/readline/readline.h ]; then echo "Found readline/readline.h include file. Enabling readline support." READLINE=1 export READLINELINK="-lreadline" break fi export READLINE wmake setSet
To this:
#!/bin/sh READLINE=0 if [ -f /usr/include/readline/readline.h ]; then echo "Found readline/readline.h include file. Enabling readline support." READLINE=1 export READLINELINK="-lreadline -lcurses" break fi export READLINE wmake setSet
12.3.2 Java tools missing
Compilation in $HOME on an x86_64 EMT64 dual cpu Gentoo machine gave:
-I/home/hoogland/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude -fPIC Make/linux64DPOpt/PatchToolServer.o Make/linux64DPOpt/IPatchToolServerImpl.o Make/linux64DPOpt/FoamXErrors.o Make/linux64DPOpt/LogEntry.o Make/linux64DPOpt/LogManager.o Make/linux64DPOpt/NameServer.o Make/linux64DPOpt/Orb.o Make/linux64DPOpt/Paths.o -L/home/hoogland/OpenFOAM/OpenFOAM-1.4.1/lib/linux64DPOpt \ -L/home/hoogland/OpenFOAM/OpenFOAM-1.4.1/src/mico-2.3.12/platforms/linux64DPOpt/lib -lmicocoss2.3.12 -lmico2.3.12 -lssl -lcrypto -ldl -lPatchToolServer -ltriSurface -ldynamicMesh -lmeshTools -lOpenFOAM -liberty -ldl -lm -o /home/hoogland/OpenFOAM/OpenFOAM-1.4.1/applications/bin/linux64DPOpt/PatchToolServer /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lPatchToolServer collect2: ld returned 1 exit status make[3]: *** [/home/hoogland/OpenFOAM/OpenFOAM-1.4.1/applications/bin/linux64DPOpt/PatchToolServer] Error 1 make[3]: Leaving directory `/home/hoogland/OpenFOAM/OpenFOAM-1.4.1/applications/utilities/mesh/manipulation/patchTool/C++/PatchToolServer' + cd Java + wmake jar make[3]: Entering directory `/home/hoogland/OpenFOAM/OpenFOAM-1.4.1/applications/utilities/mesh/manipulation/patchTool/Java' Making dependency list for source file PatchTool/PatchTool.java make[3]: Leaving directory `/home/hoogland/OpenFOAM/OpenFOAM-1.4.1/applications/utilities/mesh/manipulation/patchTool/Java' make[3]: Entering directory `/home/hoogland/OpenFOAM/OpenFOAM-1.4.1/applications/utilities/mesh/manipulation/patchTool/Java' * javac is not available for sun-jre-bin-1.6 on x86_64 * IMPORTANT: some Java tools are not available on some VMs on some architectures jar cfm ../lib/PatchTool.jar META-INF/MANIFEST.MF -C Make/classes . * jar is not available for sun-jre-bin-1.6 on x86_64 * IMPORTANT: some Java tools are not available on some VMs on some architectures make[3]: *** [../lib/PatchTool.jar] Error 1 make[3]: Leaving directory `/home/hoogland/OpenFOAM/OpenFOAM-1.4.1/applications/utilities/mesh/manipulation/patchTool/Java' make[2]: *** [patchTool] Error 2 make[2]: Leaving directory `/home/hoogland/OpenFOAM/OpenFOAM-1.4.1/applications/utilities/mesh/manipulation' make[1]: *** [manipulation] Error 2 make[1]: Leaving directory `/home/hoogland/OpenFOAM/OpenFOAM-1.4.1/applications/utilities/mesh' make: *** [mesh] Error 2 + '[' 0 = 1 -a '' = doc ']'
To see what VM's were available (using gentoo),
onceler OpenFOAM-1.4.1 # eselect java-vm list Available Java Virtual Machines: [1] blackdown-jdk-1.4.2 [2] blackdown-jre-1.4.2 [3] sun-jre-bin-1.6 system-vm
sun-jre is basically a subset of sun-jdk and does not contain tools such as javac and jar, so first sun-jdk was installed
onceler OpenFOAM-1.4.1 # emerge sun-jdk onceler OpenFOAM-1.4.1 # eselect java-vm list Available Java Virtual Machines: [1] blackdown-jdk-1.4.2 [2] blackdown-jre-1.4.2 [3] sun-jdk-1.6 [4] sun-jre-bin-1.6 system-vm
and then selected as the system wide VM,
onceler OpenFOAM-1.4.1 # eselect java-vm set system 3 onceler OpenFOAM-1.4.1 # eselect java-vm list Available Java Virtual Machines: [1] blackdown-jdk-1.4.2 [2] blackdown-jre-1.4.2 [3] sun-jdk-1.6 system-vm [4] sun-jre-bin-1.6
Availability of the necessary java tools allowed continuation of compilation.
12.3.3 Cannot find interpolatePointToCell.H while compiling foamToVTK.C
On an x86_64 Gentoo machine during an ./Allwmake, while compiling foamToVTK.C, the linker could not find interpolatePointToCell.H. A successful workaround is to manually add the necessary symbolic links in the main include directory:
hoogland@onceler ~/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude $ la interpolate* lrwxrwxrwx 1 hoogland hoogland 131 Aug 14 16:18 interpolatePointToCell.C -> /home/hoogland/OpenFOAM/OpenFOAM-1.4.1/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/interpolatePointToCell.C lrwxrwxrwx 1 hoogland hoogland 131 Aug 14 16:17 interpolatePointToCell.H -> /home/hoogland/OpenFOAM/OpenFOAM-1.4.1/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/interpolatePointToCell.H
This seems to be a gentoo problem with the location of shared libraries. The solution is to
onceler / # cd /usr/lib64 onceler lib64 # la libz* -rw-r--r-- 1 root root 105K Jul 30 14:31 libz.a -rwxr-xr-x 1 root root 324 Jul 30 14:31 libz.so onceler lib64 # la /lib64/libz* lrwxrwxrwx 1 root root 13 Jul 30 14:31 /lib64/libz.so -> libz.so.1.2.3 lrwxrwxrwx 1 root root 13 Jul 30 14:31 /lib64/libz.so.1 -> libz.so.1.2.3 -rwxr-xr-x 1 root root 80K Jul 30 14:31 /lib64/libz.so.1.2.3 onceler lib64 # mv libz.so libz.so.bak onceler lib64 # ln -s /lib64/libz.so libz.so
12.3.5 /usr/bin/ld: cannot find -lfiniteVolume
... or
/usr/bin/ld: cannot find -lsampling or
/usr/bin/ld: cannot find -lerrorEstimation or ...
These missing libraries are built if Allwmake is executed a second time in the ~/OpenFOAM/OpenFOAM-1.4.1-dev directory.
12.3.6 FoamXHostBrowser: not found
UNSOLVED
see Problem FoamXHostBrowser not found after successful compilation