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/)
-   -   How to adjust Make/options (https://www.cfd-online.com/Forums/openfoam-programming-development/73586-how-adjust-make-options.html)

bastil March 11, 2010 15:28

How to adjust Make/options
 
Hi all,

I have re-written triSurface library (MytriSurface) and placed them in FOAM_USER_LIBDIR. How I want a application to use this library. How do I need to adjust Make/options:

Code:

-I$(LIB_SRC)/MytriSurface/lnInclude
Where is LIB_SRC set and how do I need to change it? It obviously points to FOAM_SRC_DIR but I can not find any environment variable LIB_SRC?

Thanks Bastian

linch September 5, 2011 11:41

I also don't see any environment variable LIB_SRC. Where is it defined?

Regards,
illya

wyldckat September 5, 2011 14:05

Greetings to all!

(:eek: the initial post was a year and a half ago...)

OK, these kinds of variables that aren't in the shell environment, are usually defined somewhere in the wmake folder, also known as $WM_DIR:
Code:

echo $WM_DIR
Now, if you want to find out where it's located in one of those files, you can either use an advanced text editor (such as Kate or Eclipse IDE) or use the following commands:
Code:

cd $WM_DIR
find . | xargs grep 'LIB_SRC' -sl

The second line will use find to list all of the available files and folders; pipe "|" it to xargs for using each item on the list from find on grep. grep will then list the files that have the string we are searching for. Have doubts? Run:
Code:

man find
man xargs
man grep

For the lazy, the answer is as follows: it's defined in "$WM_DIR/Makefile".

Best regards,
Bruno

linch September 6, 2011 03:34

Thank you Bruno,

I saw, that the original post is very old, but since there was no answer and I was interested in, I thought I'll take the existing one instead of starting a new one.

Best regards,
Illya

wyldckat September 6, 2011 15:07

Hi Illya,

No problem :) I was more stunned by the fact that the thread didn't receive any answers back then :(

Best regards,
Bruno

Diro7 March 11, 2020 05:27

Hello Bruno,

sorry for reopening again this years-old thread but I didn't find much about these matters in the forum.

Suppose I'm writing a small custom library with some solvers and a few additional features, let's say boundary conditions or function objects. Using a tree structure similar to the OpenFOAM one now I'm able to compile such features into a single library, to the $(FOAM_USER_LIBBIN) from a customPath/src/myLibrary/ source folder.
To access such functionalities and to link the library to my solvers, now the Make/options file of my solvers should look like:

Code:

EXE_INC = \
    -IcustomPath/src/myLibrary/lnInclude \
    -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
    -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
    -I$(LIB_SRC)/transportModels \
    -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
    -I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/sampling/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude

EXE_LIBS = \
    -L$(FOAM_USER_LIBBIN) \
    -lmyLibrary \

    -lturbulenceModels \
    -lincompressibleTurbulenceModels \
    -lincompressibleTransportModels \
    -lradiationModels \
    -lfiniteVolume \
    -lsampling \
    -lmeshTools \
    -lfvOptions

Now, the -L$(FOAM_USER_LIBBIN) line specifies to look for library .so files into the $(FOAM_USER_LIBBIN) directory, such that -lmyLibrary allows to find the compiled libmyLibrary.so file. This works just fine so far.

What if I decide to compile more custom libraries separately, and I want to define something like $(LIB_USER_SRC) to point to the customPath/src base folder automatically without having to specify the whole path for each -I line?

I understand that $(LIB_SRC) is defined when calling wmake, and that to define an analogous $(LIB_USER_SRC) I could in principle either modify the wmake folder or create a custom one in my library, but this seems quite overkill.
Another possibility is maybe to define it somehow in the customPath/Allwmake script, but this would prevent me to compile solvers separately during development and testing.

Is there some possibility to define a variable pointing to the base folder within the Make/options file, just as it can be done in the Make/files file?
I know, it's more a curiosity than a real necessity, but I was wondering about it and since you are one the OpenFOAM pros around here maybe you know the tricks!

Thank you!

Andrea

ybapat March 12, 2020 00:36

You can set environment variable usign export command in linux. You can set LIB_USER_SRC to path you want.


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