CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Installation

OpenFOAM on MinGW crosscompiler hosted on Linux

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 22, 2009, 16:00
Default Hello once again to all mingw3
  #121
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hello once again to all mingw32 cross-compiling FOAMers,

I'll try to be brief: Windows version of MPICH2 fully works with mingw32 version of OpenFOAM 1.5.x! mpiexec works!!
  • Download and install in Windows the MPICH2, version 1.0.8 Win32 IA32 (binary) from here.
  • Create the folder ThirdParty/mpich2-1.0.8 in your Linux setup.
  • Copy the folders: bin, include and lib in the installed version of MPICH2 in Windows, into the folder ThirdParty/mpich2-1.0.8 in Linux.
After you apply the patches mentioned on my previous post, all you need to change is:
  • Source OpenFOAM-1.5.x/etc/settings.sh, find mpich-1.2.5 and change it to mpich2-1.0.8;
  • Source OpenFOAM-1.5.x/wmake/rules/linuxmingw32/mplibMPICH, find -lmpich and change it to -lmpi.
If you haven't yet built OpenFOAM, continue on step 8 of the previous post.
Otherwise (valid only for the WM_PSTREAMLINK="LINKTOPSTREAM", in etc/bashrc-mingw32):
  • Erase the dll's from OpenFOAM-1.5.x/lib/linuxmingw32DPOpt/ and the exe's from OpenFOAM-1.5.x/applications/bin/linuxmingw32DPOpt/;
  • Goto OpenFOAM-1.5.x/src/Pstream/mpi/ and do an wclean libso;
  • Goto back to OpenFOAM-1.5.x/ and do an ./Allwmake.
This should just link up all dll's and exe's, without having to rebuild everything! At least it worked for me ;)

Oh, and don't forget to change mpich-1.2.5 to mpich2-1.0.8 in the previously posted setvars.bat batch file.

To run with MPICH2, you must configure it properly (follow their manual, it's what I did... sort of...).
Then to launch the case, from a command window launched with setcmd.bat, goto to your case folder, and run like this:
mpiexec -n num_cores -genvlist HOME,PATH,USERNAME,WM_PROJECT_DIR,WM_PROJECT_INST_ DIR,WM_OPTIONS,FOAM_LIBBIN,FOA M_APPBIN,FOAM_USER_APPBIN,MPI_BUFFER_SIZE foamexecutable -parallel

It should work without specifying the full path to the foam executable.

Hope it works well for you too! Best Regards and happy mass-paralleling in Windows

Bruno
__________________
wyldckat is offline   Reply With Quote

Old   January 28, 2009, 18:31
Default Hi Bruno GREAT WORK... :-
  #122
Senior Member
 
Alexandre Pereira
Join Date: Mar 2009
Posts: 155
Rep Power: 17
alexandrepereira is on a distinguished road
Hi Bruno

GREAT WORK... :-D Really.. :-)

I had almost given up trying to build OF-1.5 for win...

I think that points 7.1 and 1.1 were crucial for success...

And i need it since i will have to give away my laptop for repair one of these days... and back at home nobody knows what is a real operating system... ( the PC is wi##$%& )

I had already bought an usb HDD in order to continue using OpenFOAM in Linux...

I am building ( more like trying to... :-D ) some sort of a reactingEngineDyMFoam solver to evaluate chemical kinetics in a spark Ignition engine... so I will have to use the Linux version of OF-1.5 to build my solvers, BCs and topological mesh operators... anyway, many thanks for making OpenFOAM available to W%&##$))& users... like the dumbass IT manager of CFD lab at University...!!

Thanks a lot... :-)

Alex
alexandrepereira is offline   Reply With Quote

Old   January 29, 2009, 11:06
Default Hi again Bruno, Just one qu
  #123
Senior Member
 
Alexandre Pereira
Join Date: Mar 2009
Posts: 155
Rep Power: 17
alexandrepereira is on a distinguished road
Hi again Bruno,

Just one question ,

Supposing I wanted to port some of the OF-1.5-dev applications or libraries to OF-1.5-win that I built, I should first :

Change point 1 of Symscape's tutorial in order to set the proper gcc compiler in $HOME/projects, so changing the build-mingw script.

See the structure of the patches to understand what needs to be patched in /src directory, and patch the corresponding OF-1.5-dev/src/whatever correspondingly...

Follow the rest of your setup in your detailed explanation,

... that would allow me to build OF-1.5-dev for win... is this correct...?

Regards

Alex
alexandrepereira is offline   Reply With Quote

Old   January 29, 2009, 11:36
Default Hello Alex, I'm glad my "ad
  #124
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hello Alex,

I'm glad my "add-on" posts on cross-compiling are helpful! I've been thinking about following Symscape's blog/article idea. I've already set up the blog service on our web page, but I haven't yet had the time to post the tutorial on the blog... and fix some minor glitches I've already found. Also so I can stop clogging up this forum with progress status reports and lengthy tutorials ;)

Anyway, on your note about building the latest OpenFOAM applications and/or libraries... I'll warn you that it's going to be a bit messy! By what I've seen, and I can only guess, that if you only want some of the programs, you'll probably have to build all of the new libraries, depending on the extent of updates/upgrades the project is undertaking.

Anyway, by what I remember of step 1, you don't need to change anything on that step. It's the patching up part that is going to be more complicated.
My advice is to try to use the same patches on the dev folder. Then try to adapt the patches that didn't work to the targeted files. This way, you'll start to get a grasp on what needs to be patched up and why.
Then build each library accordingly to the src/Allwmake file, so you can check what is failing, one library at a time. Oh and I advise you to set the terminal's history to infinite, because you're going to get looong error reports... and the problems usually rise from the first errors!

Other than that, I guess it's cross-compiling-business as usual.

Regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   January 30, 2009, 08:50
Default Hi Bruno I have found somet
  #125
Senior Member
 
Alexandre Pereira
Join Date: Mar 2009
Posts: 155
Rep Power: 17
alexandrepereira is on a distinguished road
Hi Bruno

I have found something strange...


I will explain :

I have my OF Linux versions in /root/OpenFOAM/...

I Have the 1.4.1, the 1.4.1-dev the 1.5 and the 1.5-dev there, so I select the one I wanto to compile my app to by changing /root/.bashrc or sourcing the OF bashrc file... its ok so far.

My "Win32" versions of OF , the 1.4.1, and the 1.5.x live in /home/alex/OpenFOAM, and my mingw32 compiler lives in /home/alex/projects and is in PATH.

The mingw32 can sucessfully compile OF-1.4.1 for win, as well as OF-1.5.x thanks to your hints...

The thing is :

I have this app, foamToTecplot, that compiles OK for both OF-1.4.1 and OF-1.5 and OF-1.5-dev LINUX versions... AND will compile OK for OF-1.4.1 WIN version... ( so it is not the compiler's changes guilt ) BUT strangely enough, it will NOT compile for my recently ( and successfully ) built OF-1.5.x WIN...

Shouldn't it do so...?

I mean : the source code does not need to be patched ( compiles OK under OF-1.4.1 win ) and it does not have unresolved library dependecies ( compiles both in OF-1.4.1 and OF-1.5 Linux versions... )

The build logs are those:


For the OF-1.4.1 "WIN" :

################################################## #############################


alex@iskandhar:~/Desktop/Utils_15/foamToTecplot$ wmake
Making dependency list for source file foamToTecplot.C
SOURCE=foamToTecplot.C ; mingw32-g++ -Dlinux -DDP -DWIN32 -DLITTLE_ENDIAN -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -O3 -DNDEBUG -DNoRepository -ftemplate-depth-40 -I/home/alex/OpenFOAM/OpenFOAM-1.4.1/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/alex/OpenFOAM/OpenFOAM-1.4.1/src/OSspecific/MSwindows/lnInclude -I/home/alex/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude -c $SOURCE -o Make/linuxmingw32DPOpt/foamToTecplot.o
mingw32-g++ -Dlinux -DDP -DWIN32 -DLITTLE_ENDIAN -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -O3 -DNDEBUG -DNoRepository -ftemplate-depth-40 -I/home/alex/OpenFOAM/OpenFOAM-1.4.1/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/alex/OpenFOAM/OpenFOAM-1.4.1/src/OSspecific/MSwindows/lnInclude -I/home/alex/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude -Wl,--enable-auto-import,--force-exe-suffix Make/linuxmingw32DPOpt/foamToTecplot.o -L/home/alex/OpenFOAM/OpenFOAM-1.4.1/lib/linuxmingw32DPOpt \
-lfiniteVolume -lOpenFOAM -lm -o /home/alex/OpenFOAM/alex-1.4.1/applications/bin/linuxmingw32DPOpt/foamToTecplot. exe
alex@iskandhar:~/Desktop/Utils_15/foamToTecplot$ wclean

################################################## ############################## ###############################

For the OF-1.5.x WIN version :

################################################## ############################## ###############################

alex@iskandhar:~/Desktop/Utils_15/foamToTecplot$ wmake
Making dependency list for source file foamToTecplot.C
SOURCE=foamToTecplot.C ; mingw32-g++ -Dlinux -DDP -DWIN32 -DLITTLE_ENDIAN -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -O3 -DNDEBUG -DNoRepository -ftemplate-depth-40 -I/home/alex/OpenFOAM/OpenFOAM-1.5.x/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/alex/OpenFOAM/OpenFOAM-1.5.x/src/OpenFOAM/lnInclude -I/home/alex/OpenFOAM/OpenFOAM-1.5.x/src/OSspecific/MSwindows/lnInclude -c $SOURCE -o Make/linuxmingw32DPOpt/foamToTecplot.o
mingw32-g++ -Dlinux -DDP -DWIN32 -DLITTLE_ENDIAN -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -O3 -DNDEBUG -DNoRepository -ftemplate-depth-40 -I/home/alex/OpenFOAM/OpenFOAM-1.5.x/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/alex/OpenFOAM/OpenFOAM-1.5.x/src/OpenFOAM/lnInclude -I/home/alex/OpenFOAM/OpenFOAM-1.5.x/src/OSspecific/MSwindows/lnInclude -Wl,--enable-auto-import,--force-exe-suffix Make/linuxmingw32DPOpt/foamToTecplot.o -L/home/alex/OpenFOAM/OpenFOAM-1.5.x/lib/linuxmingw32DPOpt \
-lfiniteVolume -lOpenFOAM -lm -o /home/alex/OpenFOAM/alex-1.5.x/applications/bin/linuxmingw32DPOpt/foamToTecplot. exe
Make/linuxmingw32DPOpt/foamToTecplot.o:foamToTecplot.C.text$_ZN4Foam14GeometricFieldIdNS_15pointPatchFie ldENS_9pointMeshEE22GeometricB oundaryField8evaluateEv[Foam::GeometricField<double,>::GeometricBoundaryFi eld::e valuate()]+0x2d6): undefined reference to `Foam::IPstream::waitRequests()'
Make/linuxmingw32DPOpt/foamToTecplot.o:foamToTecplot.C.text$_ZN4Foam14GeometricFieldIdNS_15pointPatchFie ldENS_9pointMeshEE22GeometricB oundaryField8evaluateEv[Foam::GeometricField<double,>::GeometricBoundaryFi eld::e valuate()]+0x2db): undefined reference to `Foam:Pstream::waitRequests()'
Make/linuxmingw32DPOpt/foamToTecplot.o:foamToTecplot.C.text$_ZN4Foam14GeometricFieldINS_6VectorIdEENS_15 pointPatchFieldENS_9pointMeshE E22GeometricBoundaryField8evaluateEv[Foam::GeometricField<foam::vector<double>, Foam::pointPatchField, Foam::pointMesh>::GeometricBoundaryField::evaluate ()]+0x2d5): undefined reference to `Foam::IPstream::waitRequests()'
Make/linuxmingw32DPOpt/foamToTecplot.o:foamToTecplot.C.text$_ZN4Foam14GeometricFieldINS_6VectorIdEENS_15 pointPatchFieldENS_9pointMeshE E22GeometricBoundaryField8evaluateEv[Foam::GeometricField<foam::vector<double>, Foam::pointPatchField, Foam::pointMesh>::GeometricBoundaryField::evaluate ()]+0x2da): undefined reference to `Foam:Pstream::waitRequests()'
collect2: ld returned 1 exit status
make: *** [/home/alex/OpenFOAM/alex-1.5.x/applications/bin/linuxmingw32DPOpt/foamToTecplot .exe] Error 1
alex@iskandhar:~/Desktop/Utils_15/foamToTecplot$

################################################## ############################## ###############################


For the OF-1.5 Linux version :

################################################## ############################## ###############################

root@iskandhar:/home/alex/Desktop/Utils_15/foamToTecplot# wmake
Making dependency list for source file foamToTecplot.C
SOURCE=foamToTecplot.C ; g++ -m32 -Dlinux -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-40 -I/root/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude -IlnInclude -I. -I/root/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude -I/root/OpenFOAM/OpenFOAM-1.5/src/OSspecific/Unix/lnInclude -fPIC -pthread -c $SOURCE -o Make/linuxGccDPOpt/foamToTecplot.o
g++ -m32 -Dlinux -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-40 -I/root/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude -IlnInclude -I. -I/root/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude -I/root/OpenFOAM/OpenFOAM-1.5/src/OSspecific/Unix/lnInclude -fPIC -pthread Make/linuxGccDPOpt/foamToTecplot.o -L/root/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt \
-lfiniteVolume -lOpenFOAM -ldl -lm -o /root/OpenFOAM/root-1.5/applications/bin/linuxGccDPOpt/foamToTecplot
root@iskandhar:/home/alex/Desktop/Utils_15/foamToTecplot#

################################################## ############################## ###########################################


I couldnt help noticing that in the WIN case, it actually builds the exe... but somehow, due to some compilation flags ( my guess here ) it fails to output it to the destination folder: the build log actually states that the exe was built...

I just do not know how to decrypt the rest of the build log message...


Can you give me some help here...?

I Know that if i manage to solve this issue with this application, I will solve all issues with the rest of my solvers and libraries and port them to OF-1.5.x WIN...

The pattern is the same...

Best regards

Alex
alexandrepereira is offline   Reply With Quote

Old   January 30, 2009, 12:24
Default Hello Alex, I think I've pi
  #126
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hello Alex,

I think I've pinpointed the problem. The tell-tale is "-lOpenFOAM" and the undefined reference to "IPstream" and "OPstream".

I remember you saying, and I quote:
Quote:
I think that points 7.1 and 1.1 were crucial for success...
It's point 7.1 that puts the critical difference between Symscape's 1.4.1/1.5.x patches and my 1.5.x patch: WM_PSTREAMLINK allows control over the linking method of the Pstream library. Symscape's patches simply merge the Pstream/dummy library into the OpenFOAM one. My patch allows control whether to merge the Pstream library into OpenFOAM or not! This because I followed Symscape's Pstream comment on OF 1.4.1, so I could more easily try to update or upgrade the Pstream/mpi, or even switch to the dummy version.

So, foamToTecplot would have built "out of the box" if I hadn't gone and made things "over-optional" ;)

As an example, here's what is inside OpenFOAM-1.5.x/applications/utilities/postProcessing/dataConversion/foamToVTK/Ma ke/options:
EXE_INC = \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(FOAM_UTILITIES)/postProcessing/graphics/PVFoamReader/vtkFoam

#ifdef WIN32
ifeq ("$(WM_PSTREAMLINK)","LINKTOPSTREAM")
ifneq ("$(WM_MPLIB)","NONE")
EXE_LIBS = \
-lfiniteVolume \
-llagrangian \
-lmeshTools \
-L$(FOAM_MPI_LIBBIN) -lPstream
else
EXE_LIBS = \
-lfiniteVolume \
-llagrangian \
-lmeshTools \
-L$(FOAM_LIBBIN)/dummy -lPstream
endif

else
EXE_LIBS = \
-lfiniteVolume \
-llagrangian \
-lmeshTools
endif

#else
EXE_LIBS = \
-lfiniteVolume \
-llagrangian \
-lmeshTools
#endif


So, this means that there are 4 options to linking:
  • mingw32:
    • Pstream:
      • Pstream/mpi
      • Pstream/dummy
    • OpenFOAM merged with Pstream
  • linux
I might have over done it on this. I was working late on this... and it didn't come out elegant And I did it on 80-90% of the OpenFOAM 1.5.x applications...

Alex, what's missing on foamToTecplot's is Pstream, including the -L indication on the whereabouts of that library! But following the example on foamToVTK's options, will enable your applications to be as "over-optional" as my patched version of OF 1.5.x ;)

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   January 30, 2009, 13:05
Default Thx Bruno I will give it a
  #127
Senior Member
 
Alexandre Pereira
Join Date: Mar 2009
Posts: 155
Rep Power: 17
alexandrepereira is on a distinguished road
Thx Bruno

I will give it a try in three hours...

Working at the lab now... :-)

Best regards

Alex
alexandrepereira is offline   Reply With Quote

Old   January 30, 2009, 20:08
Default Hi Bruno It worked.... :
  #128
Senior Member
 
Alexandre Pereira
Join Date: Mar 2009
Posts: 155
Rep Power: 17
alexandrepereira is on a distinguished road
Hi Bruno

It worked.... :-)

Now to the "hellish" endeavour ... build the -dev version for win...

It is absolutely not possible to port the whole of the Unix toolchain to win is it... ?

... guess not... or else it would not be called "windows"... right... :-D ...?


Regards

Alex
alexandrepereira is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenFOAM 15x MinGW Windows Port gocarts OpenFOAM Installation 1 April 17, 2009 11:41
divide by zero FPE issue in OpenFOAM 141 MingW port allenzhao OpenFOAM Installation 9 September 22, 2008 18:13
OpenFOAM on SuSE Linux 100 musahossein OpenFOAM Installation 4 June 20, 2008 17:47
OpenFoam and Linux Tomislav Maric Main CFD Forum 13 October 25, 2007 05:45
OpenFOAM and linux distros billy OpenFOAM 8 September 8, 2005 02:43


All times are GMT -4. The time now is 17:42.