CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Installation (
-   -   OpenFOAM build from source instructions (

tj22 April 6, 2006 11:48

I can't seem to find straight
I can't seem to find straight forward instructions on how to build OpenFoam. I want to build it I dont want binaries. So is it possible for someone to point me to or give me some quick instructions on how to build? how about what to download, where to extract, what environment variables to set, what files to source, what command to run to launch the build, etc.

I have tried it on my own with no luck so far with getting through complete build.

gschaider April 6, 2006 14:20

I don't want to be rude, but h
I don't want to be rude, but have you looked at the README-file (Section "4. Building from Sources (Optional)" )?

Anything more specific than that is very hard to accomplish without more detailed information about your OS, the compiler you use and the problems you are facing.

If you provide that kind of information people here are surprisingly quick with help.

tj22 April 6, 2006 15:16

Here goes: OS: Suse 10.0 gc
Here goes:
OS: Suse 10.0
gcc: 4.0.2 (included in distro)
OpenFOAM-1.3(src) in /$HOME/OpenFOAM/OpenFOAM-1.3

I looked in the readme and it seems a little confusing. It doesnt say what WM_PROJECT_INST_DIR or WM_PROJECT_DIR should be, and it looks as if the .bashrc file is based on those env vars so if I just source .bashrc the paths are wrong.

So I guessed /$HOME/OpenFOAM/OpenFOAM-1.3 to be WM_PROJECT_DIR. and if I source the .bashrc still the env vars are not quite correct.

So I located this page
and set the environment variables as described and it seems to be building, sort of. I am frequently getting these warnings(where XXXX is the path of my home dir):

"/XXXX/OpenFOAM/OpenFOAM-1.3/wmake/rules/General/java:5: /XXXX/OpenFOAM/OpenFOAM-1.3/wmake/rules/General/java: Too many open files
/XXXX/OpenFOAM/OpenFOAM-1.3/wmake/rules/linuxGcc4/c:7: /XXXX/OpenFOAM/OpenFOAM-1.3/wmake/rules/linuxGcc4/c: Too many open files
/XXXX/OpenFOAM/OpenFOAM-1.3/wmake/rules/linuxGcc4/c++:7: /XXXX/OpenFOAM/OpenFOAM-1.3/wmake/rules/linuxGcc4/c++: Too many open files
/XXXX/OpenFOAM/OpenFOAM-1.3/wmake/rules/linuxGcc4/c++:7: /XXXX/OpenFOAM/OpenFOAM-1.3/wmake/rules/linuxGcc4/c++: Too many open files"

and if I let it play out I get alot of errors exactly like this for many files:
SOURCE=icoDyMFoam.C ; g++ -m32 -Dlinux -D -Wall -W -Wno-unused-parameter -Wold-style-cast -DNoRepository -ftemplate-depth-30 -I/XXXX/OpenFOAM/OpenFOAM-1.3/src/dynamicFvMesh/lnInclude -I/XXXX/OpenFOAM/OpenFOAM-1.3/src/dynamicMesh/lnInclude -I/XXXX/OpenFOAM/OpenFOAM-1.3/src/meshTools/lnInclude -I/XXXX/OpenFOAM/OpenFOAM-1.3/src/finiteVolume/lnInclude -I/XXXX/OpenFOAM/OpenFOAM-1.3/src/OpenFOAM/lnInclude -IlnInclude -I. -fPIC -pthread -c $SOURCE -o Make/linuxGcc4/icoDyMFoam.o
<command>:1:1: error: macro names must be identifiers
make: *** [Make/linuxGcc4/icoDyMFoam.o] Error 1
+ wmake nonNewtonianIcoFoam"

Any ideas?

gschaider April 6, 2006 15:46

OK. Now we're in business. Yo
OK. Now we're in business.
Your guess for $WM_PROJECT_DIR is right (otherwise you wouldn't have gotten that far). $WM_PROJECT_INST_DIR is the parent directory.
(BTW: both variables are set in the file OpenFOAM-1.2/.OpenFOAM-1.2/bashrc which in turn sources OpenFOAM-1.2/.bashrc - try sourcing that one)

The four error messages about the open files are a classic example of an unterminated recursion:
Line 5 of wmake/rules/General/java reads:


if WM_JAVAC_OPTION is not set the line reads

include $(GENERAL_RULES)/java

which makes the file include itself (instead of for instance javaOpt) and so on. After some time make gets tired of that game and throws the above message.
Solution: make sure WM_JAVAC_OPTION is set.

The other four lines fail for similar causes. The exact solution for these is left to the reader as an exercise (I ALWAYS wanted to write that sentence ;) )

The other error leaves me a bit mystified, but maybe it will go away when you fix the first one.

brooksmoses April 6, 2006 15:48

Are you sourcing the .bashrc f
Are you sourcing the .bashrc file in $HOME/OpenFOAM/OpenFOAM-1.3? If so, that may be the problem.

You should be sourcing the bashrc (no leading dot) file in $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3. It sets up things like WM_PROJECT_DIR, and you can edit it if they're not being set up correctly.
It then sources the $HOME/OpenFOAM/OpenFOAM-1.3/.bashrc file for you, so you never need to access that directly.

tj22 April 6, 2006 16:04

That is the problem I am sourc
That is the problem I am sourcing the .bashrc in /$home/OpenFOAM/OpenFOAM-1.3. I guess I missed this in the README. Anyhow I set them up by hand prior to your posts and it seems to be building fine. I did dig down and found both this:


and also the
WM_PRECISION_OPTION which I guessed was SP or DP from looking at scalar.H

so I next time I should source $HOME/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc and that should setup everything?


brooksmoses April 6, 2006 16:14

Yes, that should set up everyt
Yes, that should set up everything!

Also, it's the file to edit if you want to change some of the settings (like the WM_PRECISION_OPTION, for instance).

gschaider April 6, 2006 16:15

Yep. Just uncomment the alt

Just uncomment the alternative for for instance WM_COMPILE_OPTION of your choice and everything SHOULD be alright.

All times are GMT -4. The time now is 23:52.