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

wmake problem with header

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By olesen

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 5, 2022, 03:44
Default wmake problem with header
  #1
New Member
 
Join Date: Aug 2021
Posts: 6
Rep Power: 4
kompe is on a distinguished road
Hi!
I am trying to follow this simple procedure to add temperature solving to icoFoam, as outlined here; https://openfoamwiki.net/index.php/H...ure_to_icoFoam


When I try to do wmake (before any changes to the code, other than renaming files), I get the following error:
Code:
/home/user/OpenFOAM/OpenFoam-v2106/src/OpenFOAM/lnInclude/face.H:52:11: fatal error: surfacePatchList.H: No such file or directory
   52 |  #include "surfacePatchList.H"
      |           ^~~~~~~~~~~~~~~~~~~~
 compilation terminated.

Do you have any idea what is going on here?
kompe is offline   Reply With Quote

Old   January 5, 2022, 09:26
Default
  #2
New Member
 
Join Date: Aug 2021
Posts: 6
Rep Power: 4
kompe is on a distinguished road
I recompiled OpenFoam with all dependencies, and now it seems to work. (Still don't know why, though.)
kompe is offline   Reply With Quote

Old   January 6, 2022, 05:10
Default
  #3
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 723
Blog Entries: 1
Rep Power: 17
dlahaye is on a distinguished road
At times it is valuable to distinguish between OpenFoam (specific) and C++ (more general).

In compiling C++ (and other languages) code one distinguishes between compiling (typically using compiler with -c option) to obtain object code (*.o file) and linking to obtain executable.

The error you point out refers to the compile stage. The compiler does not find the header (*.H) file because you haver not told the compiler where (which directory) the header file is located using the -I option.

You can look into C++ tutorials to convince yourself.
dlahaye is offline   Reply With Quote

Old   January 14, 2022, 04:17
Default
  #4
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,686
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by kompe View Post
Hi!
I am trying to follow this simple procedure to add temperature solving to icoFoam, as outlined here; https://openfoamwiki.net/index.php/H...ure_to_icoFoam


When I try to do wmake (before any changes to the code, other than renaming files), I get the following error:
Code:
/home/user/OpenFOAM/OpenFoam-v2106/src/OpenFOAM/lnInclude/face.H:52:11: fatal error: surfacePatchList.H: No such file or directory
   52 |  #include "surfacePatchList.H"
      |           ^~~~~~~~~~~~~~~~~~~~
 compilation terminated.
Do you have any idea what is going on here?

The files cannot be found, which usually happens if your changes have somehow bypassed the regular wmake mechanism. The wmakeLnInclude script is one of the helpers you are looking for.


The longer explanation: the OpenFOAM code hierarchy for each src/... directory is flattened out into a single "lnInclude" directory of symlinked files. This makes it much easier to handle since the code can then simply include the header without specifying the subdirectory path, or without adding loads of different include directories into the compilation line. When compiling a "libso" target, the wmake scripts will generate and populate the lnInclude directory with symlinks. If header files are added or moved later, it can be that they are missing from the "lnInclude" and you will have to address that yourself.

Here is what I normally do.
- Determine where the file is really located. It certainly helps if you have git installed, but the 'find' command will also work (but slower). Here is the git approach (I do it frequently enough that I actually have a git-find script with a few more options).
Code:
$  cd $WM_PROJECT_DIR
$  git ls-tree -r HEAD | grep surfacePatchList


100644 blob d25f2ede35a773fa063e0cd6f936bc98395331f4    src/surfMesh/triSurface/patches/surfacePatchList.H
As this shows, the file in question is located somewhere below the src/surfMesh hierarchy.
- use wmakeLnInclude to (re)create the corresponding symlinks.

Code:
$  cd src/surfMesh     # This is what we found in the previous step

$  wmakeLnInclude -u -pwd   # Update
Note that for the wmakeLnInclude we use the convenient '-pwd' option. This makes it easier to use (avoids errors) by locating the correct path containing the Make/ directory. That means that the following command would work equally well:
Code:
$  cd src/surfMesh/triSurface/patches     # location of the header file

$  wmakeLnInclude -u -pwd   # Update
After this the file should be properly found in the lnInclude directory and you can get on with compilation.


Side-note: sometimes if you juggle the contents of the headers and remove some included files the dependency check can get a bit wrecked (ie, it tries to check if a now nonexistent file is up-to-date). For these cases you can use the `wrmdep` to remove the old, dirty dependency file. In some cases, however, it can be useful to replace the removed file with a dummy stub such as provided in `etc/codeTemplates/removed-file`:
Code:
#warning File removed - left for old dependency check only
This ensures that the next compilation can still access the file for updating the dependency check. After it has been updated once, the file is never actually needed again.


I hope that this answers more questions than it raises.
Attached Files
File Type: txt git-find.txt (2.0 KB, 3 views)
GregNordin likes this.
olesen is offline   Reply With Quote

Old   January 17, 2022, 09:18
Default
  #5
New Member
 
Join Date: Aug 2021
Posts: 6
Rep Power: 4
kompe is on a distinguished road
Thanks a lot for your answer!
This does explain a lot. And it shows that I do not at all know as much as I would like to about the architecture of complex software and how it is managed and compiled. I usually type 'wmake' or some other code snippet I copied from somewhere and cross my fingers. I feel like a blind man when I stumble upon these sorts of errors - but thanks for shedding a little light.
kompe 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
wmake missing header files lumpor OpenFOAM Programming & Development 2 January 5, 2021 15:57
fireFoam.1.7.x_0.4 compilation error !link OpenFOAM Installation 9 December 24, 2012 04:15
wmake problem of myicoFoam. sharonyue OpenFOAM Running, Solving & CFD 1 September 17, 2012 03:08
Installation OF1.5-dev ttdtud OpenFOAM Installation 46 May 5, 2009 02:32
Problem of compilation OF 14Allwmake command not found erik_d OpenFOAM Bugs 13 September 13, 2008 21:45


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