# Problems about compiling dolfinx demos in CPP interface

**URL:** <https://fenicsproject.discourse.group/t/problems-about-compiling-dolfinx-demos-in-cpp-interface/12300>\
**Category:** dolfinx\
**Created:** [September 26, 2023, 12:27pm UTC](https://fenicsproject.discourse.group/t/problems-about-compiling-dolfinx-demos-in-cpp-interface/12300 "2023-09-26T12:27:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![WjjSteve](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/wjjsteve/32/4389_2.png) [@WjjSteve](https://fenicsproject.discourse.group/u/WjjSteve)\
**Post date:** [September 26, 2023, 12:27pm UTC](https://fenicsproject.discourse.group/t/problems-about-compiling-dolfinx-demos-in-cpp-interface/12300/1 "2023-09-26T12:27:26Z")

</div>

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

 ![image](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/6/670ab85b89b3fe43cfde6401f78a58304a939238.png)

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

 ![Screenshot from 2023-09-26 14-22-51](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/c/c7d3b1659f72443bfc9e460af845f86ae036adad.png)

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

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [September 26, 2023, 12:40pm UTC](https://fenicsproject.discourse.group/t/problems-about-compiling-dolfinx-demos-in-cpp-interface/12300/2 "2023-09-26T12:40:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![WjjSteve](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/wjjsteve/32/4389_2.png) [@WjjSteve](https://fenicsproject.discourse.group/u/WjjSteve)\
**Post date:** [September 26, 2023, 12:57pm UTC](https://fenicsproject.discourse.group/t/problems-about-compiling-dolfinx-demos-in-cpp-interface/12300/3 "2023-09-26T12:57:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [September 26, 2023, 1:08pm UTC](https://fenicsproject.discourse.group/t/problems-about-compiling-dolfinx-demos-in-cpp-interface/12300/4 "2023-09-26T13:08:04Z")

</div>

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:

> **[GitHub - FEniCS/dolfinx at v0.6.0](https://github.com/FEniCS/dolfinx/tree/v0.6.0)**
>
> v0.6.0

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

---

<div class="post-metadata">

**Author:** ![WjjSteve](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/wjjsteve/32/4389_2.png) [@WjjSteve](https://fenicsproject.discourse.group/u/WjjSteve)\
**Post date:** [September 27, 2023, 1:29pm UTC](https://fenicsproject.discourse.group/t/problems-about-compiling-dolfinx-demos-in-cpp-interface/12300/6 "2023-09-27T13:29:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [September 27, 2023, 2:10pm UTC](https://fenicsproject.discourse.group/t/problems-about-compiling-dolfinx-demos-in-cpp-interface/12300/7 "2023-09-27T14:10:21Z")

</div>

> [@WjjSteve](#):
>
> sudo add-apt-repository ppa:fenics-packages/fenics  
> sudo apt update  
> sudo apt install fenicsx

I cannot reproduce your error with a clean software environment:

`Dockerfile`:

```docker
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

```bash
docker build -t test_dx_cpp .

```

---

<div class="post-metadata">

**Author:** ![WjjSteve](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/wjjsteve/32/4389_2.png) [@WjjSteve](https://fenicsproject.discourse.group/u/WjjSteve)\
**Post date:** [September 27, 2023, 2:20pm UTC](https://fenicsproject.discourse.group/t/problems-about-compiling-dolfinx-demos-in-cpp-interface/12300/8 "2023-09-27T14:20:16Z")

</div>

> [@dokken](#):
>
> `git clone --branch=v0.6.0 --single-branch https://github.com/FEniCS/dolfinx/`

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

---

<div class="post-metadata">

**Author:** ![WjjSteve](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/wjjsteve/32/4389_2.png) [@WjjSteve](https://fenicsproject.discourse.group/u/WjjSteve)\
**Post date:** [September 27, 2023, 4:26pm UTC](https://fenicsproject.discourse.group/t/problems-about-compiling-dolfinx-demos-in-cpp-interface/12300/9 "2023-09-27T16:26:40Z")

</div>

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!
