CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   library compilation (https://www.cfd-online.com/Forums/openfoam-programming-development/91062-library-compilation.html)

foamer July 29, 2011 04:54

library compilation
 
Hi, i am quite new to openfoam.
i have looked in the user manual to compile a dynamic library, that is to issue the command wmake libso.

the error message i receive is:

Making dependency list for source file twoPhaseEulerFoam.C
could not open file createRASTurbulence.H for source file twoPhaseEulerFoam.C
could not open file wallFunctions.H for source file twoPhaseEulerFoam.C
could not open file wallDissipation.H for source file twoPhaseEulerFoam.C
could not open file wallViscosity.H for source file twoPhaseEulerFoam.C
SOURCE=twoPhaseEulerFoam.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-40 -I../bubbleFoam -I/opt/openfoam171/src/finiteVolume/lnInclude -I/opt/openfoam171/src/transportModels/incompressible/lnInclude -IturbulenceModel -IkineticTheoryModels/lnInclude -IinterfacialModels/lnInclude -IphaseModel/lnInclude -Iaveraging -IlnInclude -I. -I/opt/openfoam171/src/OpenFOAM/lnInclude -I/opt/openfoam171/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/twoPhaseEulerFoam.o
In file included from twoPhaseEulerFoam.C:54:
createFields.H:131: fatal error: createRASTurbulence.H: No such file or directory
compilation terminated.
make: *** [Make/linux64GccDPOpt/twoPhaseEulerFoam.o] Error 1


the Allwmake command gives me:
Allwclean: command not found

typing wmake does neither give me much...


could someone please help me ?

alex

bigphil July 29, 2011 05:48

Hi,


You are correct "wmake libso" is used to compile a dynamic library but wmake needs to know the location of all the header files. Also you need to be inside the library directory when you execute wmake libso.

Quote:

could not open file createRASTurbulence.H for source file twoPhaseEulerFoam.C
could not open file wallFunctions.H for source file twoPhaseEulerFoam.C
could not open file wallDissipation.H for source file twoPhaseEulerFoam.C
could not open file wallViscosity.H for source file twoPhaseEulerFoam.C
This error shows that wmake cannot find some of the files.
You can specify which directories wmake will search by putting their location in the Make/options file.

Also, isn't twoPhasaEulerFoam a solver? not a library? Solvers are compiled with the wmake command (or in the case of twoPhaseEulerFoam, you use the ./Allwmake script inside the solver directory which also compiles the included libraries).


Philip

foamer July 29, 2011 06:22

Yes, twoPhaseEulerFoam is a solver, not a library.

I tried Allwmake inside the solver directory but then i receive the answer: Allwmake: command not found

i have done some modifications in the solver..




alex

bigphil July 29, 2011 06:26

Oh OK, you need to use "./Allwmake" (ie not "Allwmake"). The dot forward slash uses the Allwmake in the current directory.

Philip

foamer July 29, 2011 08:43

Sorry Philip, my bad. i should have understood.. thank you very much.

At least it tried to compile this time, but i get the same error again (at the end):

could not open file createRASTurbulence.H for source file twoPhaseEulerFoam.C
could not open file wallFunctions.H for source file twoPhaseEulerFoam.C
could not open file wallDissipation.H for source file twoPhaseEulerFoam.C
could not open file wallViscosity.H for source file twoPhaseEulerFoam.C

I have serious problems finding the paths to the files.
Could you please help me out ?

alex

bigphil July 29, 2011 09:04

Alex,

OK try to compile each part separately to see if we can isolate the problem, so if you look in the Allwmake script (using a text editor like emacs) you will see:
Code:

wmake libso phaseModel
wmake libso interfacialModels
wmake libso kineticTheoryModels
wmake

The first three lines compile the libraries and the fourth line compiles the solver and links the libraries to the solver.

So first try:
wmake libso phaseModel
and see if you get any errors,
then do the second line and so on... and then we will find which part is at fault.

Philip

foamer July 29, 2011 09:25

Hi

I think that all of them gave me some kind of error, but i am going to let out all that is about kinetic theory. so no need to worry about that.

alex

bigphil July 29, 2011 09:43

Alex,

If you try: wmake libso phaseModel
and then paste the output here, and I will see if anything looks strange.

By the way, did twoPhaseEulerFoam compile correctly before you made modifications?

Philip

foamer July 29, 2011 09:51

Hi

The error message i got was:

/usr/bin/ld: cannot open output file /opt/openfoam171/lib/linux64GccDPOpt/libphaseModel.so: Permission denied
collect2: ld returned 1 exit status
make: *** [/opt/openfoam171/lib/linux64GccDPOpt/libphaseModel.so] Error 1


Yes, twoPhaseEulerFoam compiled correctly before the mods.

alex

bigphil July 29, 2011 10:08

Alex,

OK it is a permissions problem, wmake is trying to put the compiled libraries in a directory for which you do not have permission.
So to fix it, we just have to tell wmake to put the libraries in your $FOAM_USER_LIBBIN instead of $FOAM_LIBBIN.

In phaseModels/Make/files, change
LIB = $(FOAM_LIBBIN)/libphaseModel
to
LIB = $(FOAM_USER_LIBBIN)/libphaseModel

Then do the same in interfacialModels/Make/files and kineticTheoryModels/Make/files.

Now try wmake libso phaseModels and it should compile fine.

Also you have to tell your solver to use your libraries, so in the solver Make/options (ie twoPhaseEulerFoam/Make/options), add the following bold line:

Code:

EXE_LIBS = \
    -L$(FOAM_USER_LIBBIN) \
    -lEulerianInterfacialModels \
    -lfiniteVolume \
    -lmeshTools \
    -lincompressibleTransportModels \
    -lphaseModel \
    -lkineticTheoryModel \
    -llduSolvers

Now hopefully ./Allwmake should run fine.

Philip

foamer July 29, 2011 10:28

Hi

After i had added USER to the different models i tried wmake libso phaseModels and i got the following error:

wmake error: could not change to directory 'phaseModels'


alex

bigphil July 29, 2011 10:42

Alex,

you should be in the directory above the library when you execute wmake libso phaseModels (ie you should be in the twoPhaseEulerFoam directory where Allwmake is when you execute wmake libso phaseModels).

The error you received means wmake cannot find the phaseModels directory in the current directory.

Philip

foamer July 29, 2011 10:50

Hmm

strange because i issued the command in the following directory:

user@user-VirtualBox:~/OpenFOAM/user...haseEulerFoam$ wmake libso phaseModels


alex

foamer July 29, 2011 10:51

sorry for that

i issued the command inside the twoPhaseEulerFoam directory.

alex

bigphil July 29, 2011 10:52

Hmnnn yes strange, OK try:

cd phaseModels
wmake libso

Philip

foamer July 29, 2011 10:55

Hi

i got the following message after typing wmake libso inside phaseModels:

wmakeLnInclude: linking include files to ./lnInclude
Making dependency list for source file phaseModel/phaseModel.C
SOURCE=phaseModel/phaseModel.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-40 -I/opt/openfoam171/src/finiteVolume/lnInclude -I/opt/openfoam171/src/transportModels/incompressible/lnInclude -IlnInclude -I. -I/opt/openfoam171/src/OpenFOAM/lnInclude -I/opt/openfoam171/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/phaseModel.o
'/home/user/OpenFOAM/user-1.7.1/lib/linux64GccDPOpt/libphaseModel.so' is up to date.


alex

bigphil July 29, 2011 10:59

Great, that means it compiled fine.

Now compile the other two libraries and then the solver.

Philip

bigphil July 29, 2011 11:08

Oh and also I just realises why "wmake libso phaseModels" didn't work, it is because the library directory is called phaseModel not phaseModels.

So "wmake libso phaseModel" will work in the solver directory.

Philip

foamer July 29, 2011 11:12

Hi

the libraries compiled fine, but when i tried to compile the solver by issuing wmake inside the twoPhaseEulerFoam directory i got the following message:

Making dependency list for source file twoPhaseEulerFoam.C
could not open file createRASTurbulence.H for source file twoPhaseEulerFoam.C
could not open file wallFunctions.H for source file twoPhaseEulerFoam.C
could not open file wallDissipation.H for source file twoPhaseEulerFoam.C
could not open file wallViscosity.H for source file twoPhaseEulerFoam.C
SOURCE=twoPhaseEulerFoam.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-40 -I../bubbleFoam -I/opt/openfoam171/src/finiteVolume/lnInclude -I/opt/openfoam171/src/transportModels/incompressible/lnInclude -IturbulenceModel -IkineticTheoryModels/lnInclude -IinterfacialModels/lnInclude -IphaseModel/lnInclude -Iaveraging -IlnInclude -I. -I/opt/openfoam171/src/OpenFOAM/lnInclude -I/opt/openfoam171/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/twoPhaseEulerFoam.o
In file included from twoPhaseEulerFoam.C:54:
createFields.H:131: fatal error: createRASTurbulence.H: No such file or directory
compilation terminated.
make: *** [Make/linux64GccDPOpt/twoPhaseEulerFoam.o] Error 1


alex

bigphil July 29, 2011 11:31

Alex,

OK we're back to the original error that wmake cannot find some files. wmake looks in the directories specified in the solver Make/options file. What does your options file look like?
It should be:
Code:

EXE_INC = \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/transportModels/incompressible/lnInclude \
    -IturbulenceModel \
    -IkineticTheoryModels/lnInclude \
    -IinterfacialModels/lnInclude \
    -IphaseModel/lnInclude \
    -Iaveraging

EXE_LIBS = \
    -L$(FOAM_USER_LIBBIN) \
    -lEulerianInterfacialModels \
    -lfiniteVolume \
    -lmeshTools \
    -lincompressibleTransportModels \
    -lphaseModel \
    -lkineticTheoryModel \
    -llduSolvers

Philip

foamer August 1, 2011 02:21

Hi

It is a little different. My option file look like:

EXE_INC = \
-I../bubbleFoam \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/transportModels/incompressible/lnInclude \
-IturbulenceModel \
-IkineticTheoryModels/lnInclude \
-IinterfacialModels/lnInclude \
-IphaseModel/lnInclude \
-Iaveraging
EXE_LIBS = \
-L$(FOAM_USER_LIBBIN)\
-lEulerianInterfacialModels \
-lfiniteVolume \
-lmeshTools \
-lincompressibleTransportModels \
-lphaseModel \
-lkineticTheoryModel


Alex

bigphil August 1, 2011 13:36

Alex,

Try "wclean" and then "wmake", this will make wmake look for all the files for the solver again, it may help.

Philip

foamer August 2, 2011 02:06

it did not seem to work.

it did not compile this time either. My option file look like this:

EXE_INC = \
-I../bubbleFoam \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/transportModels/incompressible/lnInclude \
-IturbulenceModel \
-IkineticTheoryModels/lnInclude \
-IinterfacialModels/lnInclude \
-IphaseModel/lnInclude \
-Iaveraging
EXE_LIBS = \
-L$(FOAM_USER_LIBBIN)\
-lEulerianInterfacialModels \
-lfiniteVolume \
-lmeshTools \
-lincompressibleTransportModels \
-lphaseModel \
-lkineticTheoryModel


Alex

bigphil August 2, 2011 05:43

Alex,

hmmnn could you paste the output of "wclean; wmake" here so I can see?

If you want you can email me your solver and I can try compile it myself (philip DOT cardiff AT ucd DOT ie).

Philip

foamer August 2, 2011 06:17

wclean does not give me anything.

wmake gives me:

Making dependency list for source file twoPhaseEulerFoam.C
could not open file createRASTurbulence.H for source file twoPhaseEulerFoam.C
could not open file wallFunctions.H for source file twoPhaseEulerFoam.C
could not open file wallDissipation.H for source file twoPhaseEulerFoam.C
could not open file wallViscosity.H for source file twoPhaseEulerFoam.C
SOURCE=twoPhaseEulerFoam.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-40 -I../bubbleFoam -I/opt/openfoam171/src/finiteVolume/lnInclude -I/opt/openfoam171/src/transportModels/incompressible/lnInclude -IturbulenceModel -IkineticTheoryModels/lnInclude -IinterfacialModels/lnInclude -IphaseModel/lnInclude -Iaveraging -IlnInclude -I. -I/opt/openfoam171/src/OpenFOAM/lnInclude -I/opt/openfoam171/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/twoPhaseEulerFoam.o
In file included from twoPhaseEulerFoam.C:54:
createFields.H:131: fatal error: createRASTurbulence.H: No such file or directory
compilation terminated.
make: *** [Make/linux64GccDPOpt/twoPhaseEulerFoam.o] Error 1

Sorry i mislead you the other day. There is not any changes in the solver code itself. I can not compile the original one.

bigphil August 2, 2011 06:30

Alex,


OK createRASTurbulence.H is not in the default twoPhaseEulerFoam, so presumably you are trying to use the createRASTurbulence.H from bubbleFoam..?

If that is the case then add the following line to your solver Make/options
-I$(FOAM_SOLVERS)/multiphase/bubbleFoam \ instead of -I../bubbleFoam \.

Then try wclean; wmake and let me know the output.

If it still can't find createRASTurbulence.H then copy this file from bubbleFoam to your directory ie if you are in your solver directory then use the following command:
Code:

cp $FOAM_SOLVERS/multiphase/bubbleFoam/createRASTurbulence.H .
then try wclean wmake again.


Philip

foamer August 2, 2011 07:03

Hi

After i typed in "-I$(FOAM_SOLVERS)/multiphase/bubbleFoam \ instead of -I../bubbleFoam" i got the following after wclean and wmake:

options:2: warning: backslash and newline separated by space
Making dependency list for source file twoPhaseEulerFoam.C
SOURCE=twoPhaseEulerFoam.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-40 -I/opt/openfoam171/applications/solvers/multiphase/bubbleFoam -I/opt/openfoam171/src/finiteVolume/lnInclude -I/opt/openfoam171/src/transportModels/incompressible/lnInclude -IturbulenceModel -IkineticTheoryModels/lnInclude -IinterfacialModels/lnInclude -IphaseModel/lnInclude -Iaveraging -IlnInclude -I. -I/opt/openfoam171/src/OpenFOAM/lnInclude -I/opt/openfoam171/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/twoPhaseEulerFoam.o
/opt/openfoam171/src/finiteVolume/lnInclude/readPISOControls.H: In function ‘int main(int, char**)’:
/opt/openfoam171/src/finiteVolume/lnInclude/readPISOControls.H:8: warning: unused variable ‘momentumPredictor’
/opt/openfoam171/src/finiteVolume/lnInclude/readPISOControls.H:11: warning: unused variable ‘transonic’
/opt/openfoam171/src/finiteVolume/lnInclude/readPISOControls.H:14: warning: unused variable ‘nOuterCorr’
g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-40 -I/opt/openfoam171/applications/solvers/multiphase/bubbleFoam -I/opt/openfoam171/src/finiteVolume/lnInclude -I/opt/openfoam171/src/transportModels/incompressible/lnInclude -IturbulenceModel -IkineticTheoryModels/lnInclude -IinterfacialModels/lnInclude -IphaseModel/lnInclude -Iaveraging -IlnInclude -I. -I/opt/openfoam171/src/OpenFOAM/lnInclude -I/opt/openfoam171/src/OSspecific/POSIX/lnInclude -fPIC -Xlinker --add-needed Make/linux64GccDPOpt/twoPhaseEulerFoam.o -L/opt/openfoam171/lib/linux64GccDPOpt \
-L/home/user/OpenFOAM/user-1.7.1/lib/linux64GccDPOpt -lEulerianInterfacialModels -lfiniteVolume -lmeshTools -lincompressibleTransportModels -lphaseModel -lkineticTheoryModel -lOpenFOAM -liberty -ldl -lm -o /home/user/OpenFOAM/user-1.7.1/applications/bin/linux64GccDPOpt/alex


Alex

bigphil August 2, 2011 07:53

Alex,


From the output shown, your solver has compiled. The last line "-o /home/user/OpenFOAM/user-1.7.1/applications/bin/linux64GccDPOpt/alex" shows that your solver executable called alex has been output to the directory /home/user/OpenFOAM/user-1.7.1/applications/bin/linux64GccDPOpt/ (which is $FOAM_USER_APPBIN).

So you should be able to run your solver (called alex) now, just run "alex" in your case directory.

There are a few compiler warnings shown, they are three "unused variables". This means you declared the variables shown but never used them. This is not an error but make sure that you are not meant to use these variables and remove them if you don't need them.

Also the wmake warning "options:2: warning: backslash and newline separated by space" wants you to remove a space in the Make/options file.

So your solver compiles, now you just have to get it to do what you want ;)

Philip

foamer August 2, 2011 09:37

hmm

i get the following whne typing "alex":

FOAM FATAL IO ERROR:
cannot open file
file: /home/user/OpenFOAM/user-1.7.1/applications/solvers/multiphase/twoPhaseEulerFoam/system/controlDict at line 0.
From function regIOobject::readStream()
in file db/regIOobject/regIOobjectRead.C at line 61.

Alex

bigphil August 2, 2011 09:59

Alex,


You have to run your solver in your case directory (not the solver source code directory). The solver is looking for the controlDict file in the system directory of your case.

You should check out the tutorials in the user guide (http://www.openfoam.com/docs/user/).


Philip

foamer August 3, 2011 07:57

Thank you very much Philihp



Alex

bigphil August 3, 2011 08:31

No Problem,

Hopefully your solver works out for you!

Philip


All times are GMT -4. The time now is 15:04.