CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Installation on Windows, Mac and other Unsupported Platforms (
-   -   OpenFoam for MS windows (

Madhav Gentela (Gentela) December 29, 2004 14:56

Hi, Has any one tried to

Has any one tried to compile openFoam for MS Windows using Bash shell (which has all gnu utilities which are available on linux)?


Hrvoje Jasak (Hjasak) January 3, 2005 12:02

It is going to be way too har
It is going to be way too hard. Here's a few problems:

- you need to rename all the files. global.C in Microsoft is the same as global.c, so the c compiler gets called instead of C++

- some .C files (with template definitions) are included into other files: also needs changing

- Microsoft does not have sym links, so the lnInclude mechanics will not work. You will probably need full include paths everywhere

- be careful what compiler you choose: intel may be a better choice that the Microsoft (which costs money)

- the shared library loading mechanism is different: you will need tons of dllopen-s to load the libraries you need.

- the operating system/linker (not sure) do not allow cyclic dependency between shared libraries and I believe we've got lots of those. In order to sort this out you will need to re-factor all the libraries

- finally (a killer for me): Micro***t does not expose all parts of a shared library to the outside users of it. This is regulated by having dll export and dll import statements before all class definitions and global functions and operators. This is done with ifdefs and requires editing the whole of the code! I give up.

There may be other problems I've forgotten about, but my advide would be to give up because that operating system is simply too crap for the job.


Damian Merrick (Merrick) January 3, 2005 22:32

I believe Madhav may have bee
I believe Madhav may have been referring to Cygwin (see, the free set of unix tools available under Windows platforms. I think using Cygwin's unix environment, g++ etc would solve many of the problems you mentioned, although perhaps some would still remain. It would certainly be a much easier route to take than to try and port to VC++. I haven't tried compiling yet with cygwin, however... I suspect it would still require a bit of effort to get working.


Madhav Gentela (Gentela) January 4, 2005 11:12

Yup. I was referring to Cygwi
Yup. I was referring to Cygwin, which has a whole bunch of unix tools available, It simulates whole unix environment and is free. I agree with Damian, this is definitely easy route, although we need to modify Makefiles for Cygwin support (like adding Cygwin OS). Some of the command line return messages (e.g., ssh, rsh, etc) from Cygwin differ from linux shells. I am wondering if any one has already tried on Cygwin?


Andy Stone (Stone) January 4, 2005 13:32

Hi, I recently had a go at

I recently had a go at compiling with Cygwin, but eventually gave up. I solved some problems with the compilation process, but I think I came up against the cyclic dependency problem mentioned in an earlier post - as I understand it OpenFOAM compiles lots of UNIX shared objects (.so) which are similar to dlls, except that dlls require you to define all symbols at link time whereas a shared object doesn't - they can somehow be picked up from another shared object when they are both loaded into memory (excuse the vague explanation, I don't fully understand it myself). Cygwin doesn't support Unix style shared objects - it pretends to but really in the background it uses dlls, which is fine most of the time, except in the case we have here of two shared objects depending on each other.

Anyhow, here are some of the problems I did manage to solve in case you want to carry on where I gave up (this is from memory because the notes that I made at the time are elsewhere right now - if you still want to give it a go let me know and I'll give a more complete description):

To solve the install script problems I changed bits in scripts where it did something like:
machinename=`uname -s` to:
machinename=Linux (i.e. fixed it so the scripts thought they were on a Linux system).

It seems that in the source I downloaded a precompiled Linux binary had crept into the wmake directory (wmake\rules\linux\wmkdep) - I just deleted it and it was remade as part of the compilation process.

There are some problems where OpenFOAM has some headers that are called things like string.H, which on a case sensitive file system is fine, but on Cygwin causes clashes with the standard string.h header (there's a couple of others but I forget exactly which). This can be fixed by renaming to something like string_openfoam.H and using some kind of script to replace instances of #include "string.H" in the source files.

When compiling LAM using Cygwin on Win2000 (I think XP is ok) problems occur with the configure script. This requires obtaining a slightly modified bash.exe (I forget where from exactly, but if you want to know let me know and I'll find out).

The symbolic links work fine in Cygwin by the way.

I was stepping through the src\Allwmake script line by line and got to the part just after lam is compiled and installed (in the compiling Pthreads part I think) when I started getting lots of error messages about undefined symbols (which I think is down to the previously mentioned cyclic dependency). That's where I gave up and installed Linux!


Madhav Gentela (Gentela) January 4, 2005 13:42

Thanks Andy. That was good tr
Thanks Andy. That was good try. About 4 years ago, I tried cyclic dependency on MS windows. There is some way, but it was very tedious. I think one of the examples with VC++ distribution, is cyclic dependent. I have to dig through my memory, MSDN and internet search, on how to build cyclic dependent DLL's. I will try and let you know, then we can start building on CYGWIN again.


Mattijs Janssens (Mattijs) January 7, 2005 10:54

Hi, just out of curiosity:

just out of curiosity: do you guys use dlltool?


louis August 4, 2005 16:41

I am about to start building/c
I am about to start building/compiling FOAM for Windows. I have noted the problem areas given by Hrvoje. I have ideas how to solve some of the problems by 'converting' the files, include files and filenames by using scripts in a generic way. Are there any other problems you forsee running MSWindows apart from possibly re-engineering some of the code to make it work on a Windows based C++ compiler?

eugene August 5, 2005 06:47

Do yourself a favour and start
Do yourself a favour and start by porting it to cygwin or some other windows based linux emulator. That way you only have to address one or two problems at a time. (Case sensitivity and dynamic symbolic links, I think.)

hjasak August 5, 2005 07:02

Whatever you do, you will hit
Whatever you do, you will hit a problem of cyclic dependency of libraries at link-time. From what I have heard it is possible to solve this problem on a Windows platform but I could not get the details on how it's actually done. Usually, people solve this be re-arranging the libraries until they are no longer cyclically dependent on each other, but that's going to be jolly hard with 350 thousand lines of code we've got in FOAM right now.

Also, you will have tons of trouble with DLL_IMPORT and DLL_EXPORT, which means you will have to change every single source file by hand.

I'd be grateful if you could keep the forum posted on your progress.

Good luck,


gentela August 5, 2005 12:17

For DLL_IMPORT and DLL_EXPORT you can have separate file with proper syntax to specify which functions can have import and export.

Refer MSDN page : Export from a DLL Using .DEF Files core_export_from_a_dll_using_..def_files.asp

hjasak August 5, 2005 12:25

Thanks for that. This link sa
Thanks for that. This link says "Page Cannot Be Found" for me - could you please check it. Do I need to be logged in?


gentela August 5, 2005 13:30

Link worked just fine on my fi
Link worked just fine on my firefox browser. If it does not work for you, just search in gooble with following key word: "Export from a DLL Using .DEF Files" and click on first link you should see the same page.


henry August 8, 2005 09:05

The definition is in Vector.H,
The definition is in Vector.H, you are quoting vector.H.

louis August 8, 2005 09:20

Hmmm :-( When unzipping in
Hmmm :-(

When unzipping in Windows vector.H and Vector.H were overwritten ending up with only Vector.H having the contents of vector.H ....

Thanks! :-)

niklas August 8, 2005 12:27

Yes, and this has already been
Yes, and this has already been mentioned in the 'cygwin' discussion

and I can say it again, you need to unpack the files in a case-insensitive environment.

Although I have to admit that as of today, I'm now in a position where I HAVE to solve this problem, being forced to work in winblows (oops Freduian type-o)


julian April 14, 2009 01:05

OpenFOAM for MS windows
Take a look at It was said that a fully functional binary release, running natively without emulations, with ParaView 3.4.0, will be available next month.

All times are GMT -4. The time now is 22:58.