Problems about compiling dolfinx demos in CPP interface

Hi I have installed DOLFINx in Ubuntu 22.04 machine, using the following steps:

sudo add-apt-repository ppa:fenics-packages/fenics
sudo apt update
sudo apt install fenicsx

Now I want to try some demos. When I ran the python demos, it works well, but when I go the cpp, it doesn’t work anymore. Say if I’m in this directory

then I do cmake . , it seems to work well, and then I do make and got thousands of errors like this:

Are there anyone know the reason and can tell me how to fix it?
Thanks in advance!

Make sure that you checkout the appropriate branch of FEniCSx (the dolfinx repo that you have cloned), as we keep updating the github main branch, while the apt-get version is the 0.6.0 release.

Thanks for quick replying.

I think the dolfinx that I have installed is v0.6.0, as you said. So after I have cloned the repo, I should not work in the main branch? Then could you please tell me which branch contain the corresponding demos. I’m confused because the python demos in the same branch work well.
Thank you very much.

The C++ interface is a lot more explicit than the python interface, and is thus more prone to changing API.

You should use the branch:

i.e. if you used git clone, a git checkout v0.6.0 would work

Thanks.
But it still doesn’t work, if I do git checkout v0.6.0 , I will go to “detached HEAD” state, and now if I compile the codes, I got the same errors. Actually, I didn’t really see this branch in github, but there is a tag “v0.6.0”, and I also tried do ‘git checkout tags/v0.6.0’ but it doesn’t help as well.

I cannot reproduce your error with a clean software environment:

Dockerfile:

FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
    apt-get install -y software-properties-common && \
    add-apt-repository ppa:fenics-packages/fenics && \
    apt-get install -y fenicsx python3-pip

RUN apt-get install -y git


RUN git clone --branch=v0.6.0 --single-branch https://github.com/FEniCS/dolfinx/ && \
    cd dolfinx/cpp/demo/poisson && \ 
    cmake . && \
    make  && \
    ./demo_poisson

which I run with

docker build -t test_dx_cpp .

Ok, I will try to clean the dolfinx from my computer and install it again. Thanks for your patience!

Hi, I figured out. It is the enviroment issue, I have some uncleaned cmake files in some corners of my computer, maybe that caused the wrong link when I compile. After I delete them, it works well. Thanks!