Difference between revisions of "Installation/Outdated/Howto compile OpenFOAM"

From OpenFOAMWiki
m (The motivation for compiling GNU gcc)
m (Selecting the right package to download)
Line 58: Line 58:
 
===Selecting the right package to download===
 
===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 [http://gcc.gnu.org/ GCC GNU Web site], or from one of it's numerous mirrors.
 
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 [http://gcc.gnu.org/ GCC GNU Web site], or from one of it's numerous mirrors.
 +
 +
Here is an example for OpenFOAM 1.3:
 +
 +
<bash>
 +
cd $HOME/OpenFOAM/linux
 +
ftp ftp.gnu.org
 +
cd /gnu/gcc/gcc-4.1.0/
 +
bin
 +
get gcc-4.1.0.tar.bz2
 +
</bash>
  
 
===Configuration et compilation===
 
===Configuration et compilation===

Revision as of 00:57, 13 April 2006

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

This document also describes howto download and compile some of the tools 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. Depending on your Operating System and/or your OS version, your milleage may vary...

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

1 Preamble

This document describes the compilation and installation of OpenFOAM 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.


Note: 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 is usually reserved for 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.

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 describes option #3.

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:

 
cd $HOME/OpenFOAM/linux
ftp ftp.gnu.org
cd /gnu/gcc/gcc-4.1.0/
bin
get gcc-4.1.0.tar.bz2

2.3 Configuration et compilation

2.4 Installation

3 Installing the Java JSDK

4 Installing the OpenFOAM source code

5 Compiling and installing cmake

6 Compiling and installing paraView

7 Partial installation of GNU binutils (optional)

8 Miscellaneous adjustments (optional)

9 Compiling OpenFOAM


Valid versions: OF version 13.png

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