-
Notifications
You must be signed in to change notification settings - Fork 10
Loose notes on building custom code
- Preface
- Introduction
- Adapting code
- Bug fix for
wmakeVerifyExeDependencies
in blueCFD-Core 2016-1 - Using
wmakeListAllIncludedLibraries
to revise the list of necessary libraries
This wiki page aims to provide at least a few loose notes on how to build custom code with blueCFD-Core's MSys2 shell environment. Furthermore, a fair chunk of information provided here has been copied from the blueCFD-Core 2.3-1 User Guide.
Note if you're using blueCFD-Core 2016-1: Please read the Quick notes on how to update build wiki page, specially the section Setting up the work environment, to ensure you have a fully working shell environment.
With the release of OpenFOAM 2.0 came several new features, including the Run-time Code Compilation. Starting with blueCFD 2.0-1 this feature was also released, along with the capability of building custom solvers and libraries that link directly with OpenFOAM.
The reason for the original limitation regarding building OpenFOAM directly on
Windows, is the one referred to since blueCFD 1.6-1 was released: OpenFOAM's
source code relies on a case-sensitive file system, mirroring the same naming
conventions used in the C++ code. Windows only has a case-preserving file system
by default, which means that files which differ only in letter case, such as
vector.H
and Vector.H
will be overlapped and one will be forgotten.
Therefore, with the release of blueCFD 2.0-1, a semi-automatic renaming strategy
has been put into action for renaming files that most likely will collide, by
pre-pending the extension .T
to each file name and occurrence inside other
files. This criteria has been used because most files that start with an upper
case first letter are C++ templates. For example, the files vector.H
and
Vector.H
present in the original version, have the respective vector.H
and
Vector.T.H
names in blueCFD-Core's version.
At the time of this writing, the script that does the semi-automatic renaming strategy is not distributed with blueCFD-Core, because it is still in a development and proof-of-concept testing phase.
To make one's own custom solvers and libraries build in Windows, the following modifications need to be made:
- If the code to be adapted already works in Linux, then verify if there are any file collisions when unpacking in Windows.
a. This can be checked simply by unpacking the code in Windows and check if the unpacking application gives any errors.
b. Or by comparing the number of files and folders in Linux versus in Windows.
-
If there are file collisions within the custom code, then rename said files and folders in a Linux machine.
-
Next step is to rename the files that are included inside each source file. The simplest way to do this is to first try building the solver or library as-is (see step #5), as it should trigger error messages whenever a files is not found.
-
Taking into account that the heuristics used for renaming files depends on several details, for now the quickest way of checking these is to:
a. Check all #include
occurrences that include files that start with an
upper case letter. With blueCFD 2.0-2, not all files starting with an
upper letter have been renamed, e.g.: CourantNo.H
wasn't renamed because
it doesn't conflict with any other files, namely courantNo.H
doesn't
exist.
b. For those that you already know that have been renamed, check to the
previously mentioned method, e.g.: Vector.H
-> Vector.T.H
c. Double-check in the OpenFOAM-*
folder on the blueCFD-Core installation
for the occurrences of said file. For example, run in MSys2:
find $FOAM_SRC -name "Char*.H"
This will help finding out if Char.H
has been renamed to Char.T.H
or
not.
-
Build the solver by running in MSys:
wmake
Or if it is a library, then run:
wmake libso
-
Two extra steps are required when building applications, where there are libraries that are not linked by default during the final stages of
wmake
. These are:
a. Look for the missing links and add to a list the libraries to be loaded at
run time:
wmakeVerifyExeDependencies ./
Warning: If you are using blueCFD-Core 2016-1, please read the next
section Bug fix for wmakeVerifyExeDependencies
in blueCFD-Core 2016-1.
b. Then build the application once again by running:
wmake
As reported in issue #32, there is
a bug in the script wmakeVerifyExeDependencies
, as provided in blueCFD-Core
2016-1.
To apply this fix, you have at least two options, where the simplest one is to run the following commands:
foam
cd wmake
wget https://raw.githubusercontent.com/blueCFD/OpenFOAM-dev/blueCFD-Core-4.x/wmake/wmakeVerifyExeDependencies -O wmakeVerifyExeDependencies
This will get you the updated script and should fix the problem.
The other option is to get the latest developments and update the build as instructed here: Quick notes on how to update build - although this is a considerably time-consuming effort to rebuild from source code, but at least it will get you the latest bug fixes..
WARNING: Only fully operational as of blueCFD-Core 2024-1.
When compiling libraries and applications for Windows, it is strictly necessary to list all libraries that it should link to. For this purpose, the script wmakeListAllIncludedLibraries
has been introduced into blueCFD-Core's port for adding the necessary library dependencies, based on the libraries being included to search for headers.
Usage examples:
-
With a library or application (e.g. on OpenFOAM 12):
sol cd chemFoam wmakeListAllIncludedLibraries
-
It added the following to the file
Make/options
:EXE_LIBS += \ -lfluidThermophysicalModels \ -lphysicalProperties \ -lspecie \ -lmulticomponentThermophysicalModels \ -lODE \
-
-
With a dynamic code template file (e.g. on OpenFOAM 12):
foam cd etc/codeTemplates/dynamicCode wmakeListAllIncludedLibraries fluidThermo
-
It added the following to the file
fluidThermo
:LIB_LIBS += \ -lphysicalProperties \ -lspecie \ -lthermophysicalProperties \ -lfluidThermophysicalModels \ -lfiniteVolume
-
Which needs to be moved into the correct section of the file:
codeOptions #{ EXE_INC = \ -I$(LIB_SRC)/physicalProperties/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/thermophysicalProperties/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude LIB_LIBS += \ -lphysicalProperties \ -lspecie \ -lthermophysicalProperties \ -lfluidThermophysicalModels \ -lfiniteVolume #};
-
This wiki uses the GNU Free Documentation License 1.3