Poisson.h not found in dolfinx for C++

Hello,
I managed to succesfully install dolfinx on OSX. The make install command outputs, at the end,

DOLFINx has now been installed in

    /usr/local

and demo programs have been installed in

    /usr/local/share/dolfinx/demo

Don't forget to update your environment variables. This can be done
easily using the helper file 'dolfinx.conf' which sets the appropriate
variables (for users of the Bash shell).

The folder /usr/local/share/dolfinx/demo does not exist. However, I found some .cpp demos in /dolfinx-0.7.3/cpp/demo/, for example a demo of the solution of Poisson equation in /dolfinx-0.7.3/cpp/demo/poisson, where there is the file main.cpp.

However, when I try to compile main.cpp, it does not find the poisson.h header:

% g++ main.cpp -o main.o -I/Applications/boost_1_83_0            
main.cpp:90:10: fatal error: 'poisson.h' file not found
#include "poisson.h"
         ^~~~~~~~~~~
1 error generated.

Where is this header located ?
Thank you !

The header should be automatically generated using ffcx. This is part of the configuration step in the CMakeLists.txt file.

E.g: on my system with a clean repostory:

dolfinx/cpp/demo/poisson
β”œβ”€β”€ CMakeLists.txt
β”œβ”€β”€ main.cpp
└── poisson.py

and after cd dolfinx/cpp/demo/poisson && ffcx poisson.py && cd -

dolfinx/cpp/demo/poisson/
β”œβ”€β”€ CMakeLists.txt
β”œβ”€β”€ main.cpp
β”œβ”€β”€ poisson.c
β”œβ”€β”€ poisson.h
└── poisson.py

Thank you, that generated poisson.h indeed. Now I get another error,

 % 
cd /Applications/dolfinx-0.7.3/cpp/demo/poisson
ffcx poisson.py 
% ls
CMakeCache.txt		CMakeLists.txt		cmake_install.cmake	poisson.c		poisson.py
CMakeFiles		Makefile		main.cpp		poisson.h
 % g++ main.cpp -o main.o -I/Applications/boost_1_83_0  
In file included from main.cpp:90:
./poisson.h:18:10: fatal error: 'ufcx.h' file not found
#include <ufcx.h>
         ^~~~~~~~
1 error generated.

May you please let me know where to find the ufcx.h file? I cannot find it …
Thanks

This shouldn’t need to be found manually. It’s not clear to me how you’ve installed dolfinx and its dependencies. But you can get the path with:

python3 -c "import ffcx.codegeneration; print(ffcx.codegeneration.get_include_path())"

Once you run cmake in that folder there is a Makefile: you must use β€œmake” to compile, not trying to write your own call to g++ main.cpp -o main.o -I/Applications/boost_1_83_0

1 Like