# Expression: unable to compile C++ code

**URL:** <https://fenicsproject.discourse.group/t/expression-unable-to-compile-c-code/2936>\
**Category:** Uncategorized\
**Created:** [April 16, 2020, 6:23am UTC](https://fenicsproject.discourse.group/t/expression-unable-to-compile-c-code/2936 "2020-04-16T06:23:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![michi-ost](https://avatars.discourse-cdn.com/v4/letter/m/41988e/32.png) [@michi-ost](https://fenicsproject.discourse.group/u/michi-ost)\
**Post date:** [April 16, 2020, 6:23am UTC](https://fenicsproject.discourse.group/t/expression-unable-to-compile-c-code/2936/1 "2020-04-16T06:23:52Z")

</div>

Hi

I want to use a expression to define a time-depending load. Something like this:

```
T = 3
p01 = -1.
p03 = -1.
cutoff_Tc = 1
 # Define the loading as an expression depending on t
p1 = Expression(("0", "t <= tc ? p01*t/tc : p03", "0"), t=0, tc=cutoff_Tc, p01=p01, p03=p03, degree=0)

```

But I get a RuntimeError as follows:

```
RuntimeError: Unable to compile C++ code with dijitso

```

Fenics 2019.1.0 on Ubuntu

What did I wrong?  
Thanks for help

---

<div class="post-metadata">

**Author:** ![kamensky](https://avatars.discourse-cdn.com/v4/letter/k/e95f7d/32.png) [@kamensky](https://fenicsproject.discourse.group/u/kamensky)\
**Post date:** [April 16, 2020, 2:52pm UTC](https://fenicsproject.discourse.group/t/expression-unable-to-compile-c-code/2936/2 "2020-04-16T14:52:17Z")

</div>

I’m not getting any error with the MWE. The following runs for me using FEniCS 2019.1.0:

```python
from dolfin import *
T = 3
p01 = -1.
p03 = -1.
cutoff_Tc = 1
 # Define the loading as an expression depending on t
p1 = Expression(("0", "t <= tc ? p01*t/tc : p03", "0"),
                t=0, tc=cutoff_Tc, p01=p01, p03=p03, degree=0)
for i in range(0,3):
    print(assemble(p1[i]*dx(domain=UnitIntervalMesh(1))))

```

---

<div class="post-metadata">

**Author:** ![nate](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/nate/32/17_2.png) [@nate](https://fenicsproject.discourse.group/u/nate)\
**Post date:** [April 16, 2020, 2:56pm UTC](https://fenicsproject.discourse.group/t/expression-unable-to-compile-c-code/2936/3 "2020-04-16T14:56:20Z")

</div>

Maybe do a quick

```bash
dijitso clean

```

This will clear the cache and recompile from scratch.

---

<div class="post-metadata">

**Author:** ![michi-ost](https://avatars.discourse-cdn.com/v4/letter/m/41988e/32.png) [@michi-ost](https://fenicsproject.discourse.group/u/michi-ost)\
**Post date:** [April 17, 2020, 5:23am UTC](https://fenicsproject.discourse.group/t/expression-unable-to-compile-c-code/2936/4 "2020-04-17T05:23:48Z")

</div>

Thanks for your help, but it still does not work…  
I tried also: `dijitso.cmdline.cmd_clean()` …here I am not sure what the arguments should be in `dijitso.cmdline.cmd_clean(args, params)`

Do you have an other idea?

---

<div class="post-metadata">

**Author:** ![hateaf](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/hateaf/32/1041_2.png) [@hateaf](https://fenicsproject.discourse.group/u/hateaf)\
**Post date:** [April 17, 2020, 5:08pm UTC](https://fenicsproject.discourse.group/t/expression-unable-to-compile-c-code/2936/5 "2020-04-17T17:08:17Z")

</div>

you probably need to write a class.

---

<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:** [April 17, 2020, 6:40pm UTC](https://fenicsproject.discourse.group/t/expression-unable-to-compile-c-code/2936/6 "2020-04-17T18:40:48Z")

</div>

`ditjitso clean` can be called in a terminal.

---

<div class="post-metadata">

**Author:** ![nate](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/nate/32/17_2.png) [@nate](https://fenicsproject.discourse.group/u/nate)\
**Post date:** [April 17, 2020, 6:52pm UTC](https://fenicsproject.discourse.group/t/expression-unable-to-compile-c-code/2936/7 "2020-04-17T18:52:12Z")

</div>

The error message should also have a file name of the compilation log which could help you.

---

<div class="post-metadata">

**Author:** ![michi-ost](https://avatars.discourse-cdn.com/v4/letter/m/41988e/32.png) [@michi-ost](https://fenicsproject.discourse.group/u/michi-ost)\
**Post date:** [April 20, 2020, 7:55am UTC](https://fenicsproject.discourse.group/t/expression-unable-to-compile-c-code/2936/8 "2020-04-20T07:55:46Z")

</div>

Hi nate

The error.log file says that there is no Expression.h file, but it exists.  
And it worked before…

```
    /tmp/tmpi1ft54_x/dolfin_expression_c724df7a690a4ccbba6d7cc00af10c2b.cpp:13:10: fatal error: dolfin/function/Expression.h: No such file or directory
 #include <dolfin/function/Expression.h>
      ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
```
