CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Pre-Processing (https://www.cfd-online.com/Forums/openfoam-pre-processing/)
-   -   Compiling with exe option (https://www.cfd-online.com/Forums/openfoam-pre-processing/62089-compiling-exe-option.html)

maka January 2, 2007 09:18

I tried to recompile icoFoam w
 
I tried to recompile icoFoam with: wmake exe to generate a single executable file that does not depend on the dynamically linked libraries.

I got the following error:
-------------------------
wmake exe
make: Nothing to be done for `allFiles'.
make: `Make/linuxAMD64Gcc4DPOpt/dependencies' is up to date.
exe
/data/maka/OpenFOAM/OpenFOAM-1.3/wmake/bashScripts/mkObjectDir a.out
g++ -m64 -DlinuxAMD64 -DDP -Wall -W -Wno-unused-parameter -Wold-style-cast -march=opteron -O3 -DNoRepository -ftemplate-depth-30 -I/data/maka/OpenFOAM/OpenFOAM-1.3/src/finiteVolume/lnInclude -I/data/maka/OpenFOAM/OpenFOAM-1.3/src/OpenFOAM/lnInclude -IlnInclude -I. -fPIC Make/linuxAMD64Gcc4DPOpt/icoFoam.o -lfiniteVolume \
-liberty -o a.out
/usr/bin/ld: cannot find -lfiniteVolume
collect2: ld returned 1 exit status
make: *** [a.out] Error 1
------------------------------

This was motivated by the fact that I have very limited account space on the cluster which I run on.

I understand that copying the necessary dynamically linked objects together with the normal executable (generated by wmake) will work but it is still too big. Also using shared object saves space if I'm going to copy lots of solvers but this is not the case.

I wonder if there is a way to generate a single executable file for a solver?

Thanks,
Maka

mattijs January 2, 2007 17:18

you might want to 'strip' the
 
you might want to 'strip' the libraries. E.g. libOpenFOAM.so went down from 4204464 to 3553312 bytes in my case.

Or maybe you are allowed to run on a bigger local partition (/usr/tmp?) and can create a local installation there on every node.

mattijs February 27, 2008 04:18

wmake exe is used to create an
 
wmake exe is used to create an executable which is independent of the Foam libraries, i.e. does not need any Foam functionality.

What you want to do instead is to created static libraries (.a) versions of all the OpenFOAM libraries ('wmake lib' instead of 'wmake libso') and then build the executable without -shared (not sure if that is an option in wmake).

Much easier is just to run a tool like statifier to convert executable and libraries into a single standalone executable.

psosnows September 17, 2010 06:30

Hello,

similarly to Maka, I would like to compile my solver and create single executable file. I would like to be able to copy that "exe" file to a machine (cluster) which does not have OF installed.

While using "wmake exe" I get the same error:

/usr/bin/ld: cannot find -lfiniteVolume
collect2: ld returned 1 exit status
make: *** [a.out] Error 1

I understand that this is some problem with linking everything together.
Right now I am running on OF-1.7.1, installed as default in /opt/ folder.
Running sole "wmake" works properly.

I kindly ask for some hints.
Best,
Pawel

wyldckat September 17, 2010 20:59

Greetings Pawel,

AFAIK: the current version of OpenFOAM has some dependencies on the etc folder available in OpenFOAM's version folder (e.g. OpenFOAM-1.7.1). So, even if you wanted a fully stand-alone binary of a solver from OpenFOAM, that simply can't be done without some re-engineering of the code.
So, I think the simplest thing you could do is to run:
Code:

cd $FOAM_APPBIN
ldd solver

This will output the list of libraries that your desired solver needs. Then use this list for copying both the solver binary and those select few libraries into a single folder, and "ship-it" along with OpenFOAM's etc folder. Keep in mind that some of OpenFOAM's environment variables are still necessary, even it you stuff everything into the same folder ;).

I think this solution is the quickest nonetheless and is the one with the smallest disk space footprint, if you only need one or two solvers. Because if you build all applications in static mode, you binary folder will jump from 0.5-1 MB per binary, to 20-30 MB per binary!


Now, if you still want to build static executables of OpenFOAM applications, then I suggest that you study the solution I implemented on the patches for cross-compiling OpenFOAM in Linux for Windows, available here. In the section "Profiling OpenFOAM applications with mingw cross-compiled version" of that page, you will find a short explanation of why I implemented this solution and where you can find the necessary changes for making static builds of OpenFOAM applications. Keep in mind that these changes are strictly adapted to compiling with mingw and in Profiling mode. In other words, Profiling mode for Linux will not give you the same static builds as with mingw! But changing it to work with Optimized version for Linux should be pretty easy!!


Additionally, you can also search OpenFOAM's forums for "static builds for Cray" (if I'm not mistaken), because there have been some people that needed to build static executables, due to some of Cray's limitations or the compiler's limitations, I'm not sure...

Best regards,
Bruno

psosnows September 18, 2010 07:20

Hello Bruno,

thank you very much for your fast and comprehensive replay! Finally I am out of a black alley. Will give a feedback on the results as soon as I obtain them (hopefully on Monday).

Best,
Pawel

seboxx September 14, 2011 11:41

Hi Pawel,

is there any news related to this topic?
I have the same situation, I want to use a cluster that has no OpenFOAM environment installed. And I do think the best solution is a stand-alone binary.
I haven't found any solution yet and am happy about any hint.

Best regards,
sebastian

psosnows September 14, 2011 12:10

Hello Sebastian,

In the end I followed Bruno's advice (some posts above) and took the libraries "with me" to the cluster, without creating one, big exe. It worked but required quite a lot of digging, to bring the right lib* files.

Later on we moved to another cluster with OF installed, so the problem varnished.

Hope you will fight the way through!
Best,
Pawel

seboxx September 14, 2011 12:54

Well thanks for the quick reply :)

Not that I didnt try it... but I keep on getting this error message:

error while loading shared libraries: libfiniteVolume.so: cannot open shared object file: No such file or directory

wyldckat September 16, 2011 19:54

Greetings to all,

Just to let you all and anyone else know that the subject on this thread has been continued on another thread: http://www.cfd-online.com/Forums/ope...le-solver.html

Best regards,
Bruno


All times are GMT -4. The time now is 16:51.