Can't define Expression through c++; returns fatal error: ufc.h: No such file or directory

I answer to all your questions below:

No sorry I diddn’t. I though it was not interesting for you.
This is the content of the folder:

$ ls
dolfin_expression_daaaa038f9fbf86571aa796b263f0180.cpp  error.log  error.log.old  README  recompile.sh

Where recompile.sh gives the same information reported in error.log and error.log.old. If that’s of your interest, I can provide you the content of the cpp class in another comment.


There is no log folder or log file in ~/.cache/dijitso. there are only two folders, called include and lib, both of them empty.


There’s something inside that folder, but nothing that is clearly related to fenics. At least for me:

~/.local/lib/python3.8/site-packages$ ls
appdirs-1.4.4.dist-info  clonevirtualenv.py  distlib-0.3.1.dist-info    filelock.py  pipenv-2020.11.15.dist-info  virtualenv                   virtualenv_clone-0.5.4.dist-info
appdirs.py               distlib             filelock-3.0.12.dist-info  pipenv       __pycache__                  virtualenv-20.3.1.dist-info

Is there maybe any folder or file you would like me to inspect further?

The local python path looks clean with respect to fenics, but inspect also /usr/local/lib/python3*/dist-packages/.

I think there must be more information in the jitfailure files. You reported the error message, but you haven’t reported what was actually executed. recompile.sh can’t have the same content as error.log, it contains the command that triggers the error, it should be a c++ line.

Dear @dparsons ,
Thank you again a lot for dedicating so much time to my issue. I am answering you below:

I inspected it and here’s what I get:

$ ls /usr/local/lib/python3*/dist-packages
cycler-0.10.0.dist-info                    matplotlib                        __pycache__
cycler.py                                  matplotlib-3.3.4.dist-info        pylab.py
kiwisolver-1.3.1.dist-info                 matplotlib-3.3.4-py3.8-nspkg.pth  pyparsing-2.4.7.dist-info
kiwisolver.cpython-38-x86_64-linux-gnu.so  mpl_toolkits                      pyparsing.py

I don’t know if any of these packages may be causing the issue. Maybe kiwisolver?


Excuse me, do you mean the python code that generated the error? To obtain this error, I simply ran the code you suggested before:

python3 -c "import fenics; ccode = 'x[0] < 64 ? 1 : 0'; expression = fenics.Expression(ccode, degree=1); print(expression)"

But maybe I did’t get what you mean. Tell me whatever you need to know and I’ll be happy to tell you.


You are right, I’m sorry. What I meant is that running sh recompile.sh you get the same output of the error.log file, but I didn’t though of checking how the file actually looks like with vim. Here’s the actual content of the file (I broke the line to make it more readable):

#!/bin/bash
# Execute this file to recompile locally
c++ -Wall -shared -fPIC -std=c++11 -O3 -fno-math-errno 
-fno-trapping-math -ffinite-math-only -I/usr/local/include 
-I/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/include 
-I/usr/lib/slepcdir/slepc3.12/x86_64-linux-gnu-real/include 
-I/usr/lib/x86_64-linux-gnu/openmpi/include 
-I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi 
-I/usr/include/hdf5/openmpi -I/usr/include/eigen3 
-I/home/francop/.local/share/virtualenvs/prova-pipenv-7FqKejdp/src/fenics-ffc/ffc/backends/ufc 
-I/home/francop/.cache/dijitso/include dolfin_expression_daaaa038f9fbf86571aa796b263f0180.cpp 
-L/usr/lib/x86_64-linux-gnu/openmpi/lib 
-L/usr/lib/petscdir/petsc3.12/x86_64-linux-gnu-real/lib 
-L/usr/lib/slepcdir/slepc3.12/x86_64-linux-gnu-real/lib 
-L/usr/lib/x86_64-linux-gnu/hdf5/openmpi 
-L/usr/local/lib 
-L/home/francop/.cache/dijitso/lib 
-Wl,-rpath,/home/francop/.cache/dijitso/lib
-lmpi -lmpi_cxx -lpetsc_real -lslepc_real -lm -ldl -lz -lsz -lhdf5 -lboost_timer 
-ldolfin -olibdijitso-dolfin_expression_daaaa038f9fbf86571aa796b263f0180.so

And, even though I’m not an expert, I guess that’s the part causing the issue:

-I/home/francop/.local/share/virtualenvs/prova-pipenv-7FqKejdp/src/fenics-ffc/ffc/backends/ufc

For some reason it looks for ffc in a pipenv enivronment. Interestingly, that’s not the virtualenv mentioned earlier on the topic, but another random virtualenv I created today (after I encoutered this issue the first time).
I tried to delete the folder containing the environment, but this didn’t solve the issue (and the recompile.sh is still the same). Any other ideas?

Exactly. There’s your problem right there, your calculation is captured by some virtualenv. You need to work out how that started. They’re in your ~/.local. You need to take control of that and stop the virtualenv from interfering.

Dear @dparsons,
I finally managed to solve the issue without reinstalling Ubuntu (so far at least).

Long story short:

I uninstalled fenics and reinstalled it building it from source (stable version) following the instructions here.

Then, I noticed that the recompile.sh was unchanged and this made me understand that the libraries to import must have been written to some file.

After a lot of research, I found that there was a configuration file in /usr/local/lib/pkgconfig/ called dolfin.pc, which included the wrong path I mentioned in my last comment

Changing dolfin.pc to include the correct library finally solved the issue.

Thank you a lot for dedicating so much to the issue.

Just a note: building from source I installed the version 2019.1.0, which does not include a lot of useful solvers and preconditioners like mumps and hypre_euclid. Are these things only in the version 2019.2.0.dev0? I used that version before and they were included

No, access to solvers is provided through PETSc. You must have made a local build of petsc during your installation which misses those features. It sounds like your usage would be better served by the Ubuntu builds, though you’ll gain experience doing the handmade local builds.