# Installation of precice v2 and its openfoam-adapter

**URL:** <https://precice.discourse.group/t/installation-of-precice-v2-and-its-openfoam-adapter/171>\
**Category:** Installing preCICE\
**Tags:** openfoam, adapters, configuration\
**Created:** [March 10, 2020, 9:55am UTC](https://precice.discourse.group/t/installation-of-precice-v2-and-its-openfoam-adapter/171 "2020-03-10T09:55:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dashqua](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/dashqua/32/115_2.png) [@dashqua](https://precice.discourse.group/u/dashqua)\
**Post date:** [March 10, 2020, 9:55am UTC](https://precice.discourse.group/t/installation-of-precice-v2-and-its-openfoam-adapter/171/1 "2020-03-10T09:55:35Z")

</div>

Hi all,  
I wanted to switch my precice installation from v1 to v2 so I uninstalled everything (libprecice + openfoam-adapter) and now I am having trouble with installing openfoam-adapter.  
I was able to pass the tests after installing precice v2 (via sources or debian package) but I think the installation did not go well because if I run **binprecice** , the output is:

```
binprecice: error while loading shared libraries: libprecice.so.2: cannot open shared object file: No such file or directory

```

It looks to me that there might be a confusion between /usr/local and /usr but I am not an expert in this. If somebody can review the installation process with me, it would be great !

Let us say I download this [package](https://github.com/precice/precice/releases/download/v2.0.1/libprecice2_2.0.1_bionic.deb).

1. How can I make sure there won’t be any conflict with any previous installation of precice v1 or v2 that I tried to install/uninstall ?

2. if everything’s fine, should I just use

Many thanks for your support

---

<div class="post-metadata">

**Author:** ![dashqua](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/dashqua/32/115_2.png) [@dashqua](https://precice.discourse.group/u/dashqua)\
**Post date:** [March 10, 2020, 10:11am UTC](https://precice.discourse.group/t/installation-of-precice-v2-and-its-openfoam-adapter/171/2 "2020-03-10T10:11:22Z")

</div>

After more consideration, I think my installation of libprecice is valid.  
However, when I run **./Allwmake** for openfoam-adapter, I get the following log:

> Building the OpenFOAM adapter for preCICE…
> 
> Current OpenFOAM environment:  
> WM\_PROJECT = OpenFOAM  
> WM\_PROJECT\_VERSION = 6
> 
> The adapter will be built into:  
> ADAPTER\_TARGET\_DIR = /home/tdg/OpenFOAM/tdg-6/platforms/linux64GccDPInt64Opt/lib
> 
> The following building options will be used:  
> ADAPTER\_PREP\_FLAGS = -DADAPTER\_DEBUG\_MODE  
> ADAPTER\_WMAKE\_OPTIONS = -j 20
> 
> Dependencies (preCICE) will be located using the following environment variables:  
> ADAPTER\_PRECICE\_ROOT =  
> preCICE dependencies: not specified (ok if preCICE is built as a shared library)  
> ADAPTER\_PKG\_CONFIG\_CFLAGS = -I/usr/local/include  
> ADAPTER\_PKG\_CONFIG\_LIBS = -L/usr/local/lib -lprecice  
> ADAPTER\_GLOBAL\_CPLUS\_INC\_PATHS =  
> ADAPTER\_GLOBAL\_LD\_LIBRARY\_PATHS = -L/mnt/datasim/OpenFOAM/ThirdParty-6/platforms/linux64Gcc/gperftools-svn/lib -L/mnt/datasim/OpenFOAM/ThirdParty-6/platforms/linux64Gcc/ParaView-5.4.0/lib/paraview-5.4 -L/mnt/datasim/OpenFOAM/OpenFOAM-6/platforms/linux64GccDPInt64Opt/lib/openmpi-system -L/mnt/datasim/OpenFOAM/ThirdParty-6/platforms/linux64GccDPInt64/lib/openmpi-system -L/usr/lib/x86\_64-linux-gnu/openmpi/lib -L/home/tdg/OpenFOAM/tdg-6/platforms/linux64GccDPInt64Opt/lib -L/mnt/datasim/OpenFOAM/site/6/platforms/linux64GccDPInt64Opt/lib -L/mnt/datasim/OpenFOAM/OpenFOAM-6/platforms/linux64GccDPInt64Opt/lib -L/mnt/datasim/OpenFOAM/ThirdParty-6/platforms/linux64GccDPInt64/lib -L/mnt/datasim/OpenFOAM/OpenFOAM-6/platforms/linux64GccDPInt64Opt/lib/dummy  
> ADAPTER\_GLOBAL\_LIBRARY\_PATHS =
> 
> Building with WMake (see the wmake.log log file)…
> 
> === ERROR: Building failed. See wmake.log for more. ===  
> Possible causes:
> 
> - Make sure you are using a compatible version of the adapter for your OpenFOAM version:  
> [Notes on OpenFOAM · precice/openfoam-adapter Wiki · GitHub](https://github.com/precice/openfoam-adapter/wiki/Notes-on-OpenFOAM)
> - Is preCICE discoverable at compile time? Check the content of ADAPTER\_PKG\_CONFIG\_CFLAGS above.

Also in step 3 of the [installation tutorial](https://github.com/precice/openfoam-adapter/wiki/Building), it is said i may have to adapt to a specific branch of the adapter. The above log was made with the master branch. I pulled the branch related to my OF version (OF6) with the following command:

```
git clone --single-branch --branch OpenFOAM6 https://github.com/precice/openfoam-adapter.git

```

And the only change I do in **./Allwmake** is :

```
ADAPTER_WMAKE_OPTIONS="-j $(nproc)"

```

And when I run the **./Allwmake** I obtain

```
Building the OpenFOAM adapter for preCICE...

Current OpenFOAM environment:
  WM_PROJECT = OpenFOAM
  WM_PROJECT_VERSION = 6

The adapter will be built into:
  ADAPTER_TARGET_DIR = /home/tdg/OpenFOAM/tdg-6/platforms/linux64GccDPInt64Opt/lib

The following building options will be used:
  ADAPTER_PREP_FLAGS = -DADAPTER_DEBUG_MODE
  ADAPTER_WMAKE_OPTIONS = -j 20

Dependencies (preCICE) will be located using the following environment variables:
  ADAPTER_PRECICE_ROOT =
      preCICE dependencies: not specified (ok if preCICE is built as a shared library)
  ADAPTER_PKG_CONFIG_CFLAGS = -I/usr/local/include
  ADAPTER_PKG_CONFIG_LIBS = -L/usr/local/lib -lprecice
  ADAPTER_GLOBAL_CPLUS_INC_PATHS =
  ADAPTER_GLOBAL_LD_LIBRARY_PATHS = -L/mnt/datasim/OpenFOAM/ThirdParty-6/platforms/linux64Gcc/gperftools-svn/lib -L/mnt/datasim/OpenFOAM/ThirdParty-6/platforms/linux64Gcc/ParaView-5.4.0/lib/paraview-5.4 -L/mnt/datasim/OpenFOAM/OpenFOAM-6/platforms/linux64GccDPInt64Opt/lib/openmpi-system -L/mnt/datasim/OpenFOAM/ThirdParty-6/platforms/linux64GccDPInt64/lib/openmpi-system -L/usr/lib/x86_64-linux-gnu/openmpi/lib -L/home/tdg/OpenFOAM/tdg-6/platforms/linux64GccDPInt64Opt/lib -L/mnt/datasim/OpenFOAM/site/6/platforms/linux64GccDPInt64Opt/lib -L/mnt/datasim/OpenFOAM/OpenFOAM-6/platforms/linux64GccDPInt64Opt/lib -L/mnt/datasim/OpenFOAM/ThirdParty-6/platforms/linux64GccDPInt64/lib -L/mnt/datasim/OpenFOAM/OpenFOAM-6/platforms/linux64GccDPInt64Opt/lib/dummy
  ADAPTER_GLOBAL_LIBRARY_PATHS =

Building with WMake (see the wmake.log log file)...

=== ERROR: Building completed with linking problems: there were undefined symbols. ===
Possible causes:
- Is preCICE discoverable at runtime? Check the content of ADAPTER_PKG_CONFIG_LIBS and ADAPTER_GLOBAL_LD_LIBRARY_PATHS above.
- If preCICE is (in purpose) only build as a static library, please set the ADAPTER_PRECICE_DEP in this script appropriately (see comments).
See wmake.log and ldd.log for more details.

```

---

<div class="post-metadata">

**Author:** ![dashqua](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/dashqua/32/115_2.png) [@dashqua](https://precice.discourse.group/u/dashqua)\
**Post date:** [March 10, 2020, 2:06pm UTC](https://precice.discourse.group/t/installation-of-precice-v2-and-its-openfoam-adapter/171/3 "2020-03-10T14:06:30Z")

</div>

Here are the [log files](https://gofile.io/?c=j62QLZ)

---

<div class="post-metadata">

**Author:** ![dashqua](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/dashqua/32/115_2.png) [@dashqua](https://precice.discourse.group/u/dashqua)\
**Post date:** [March 11, 2020, 7:57am UTC](https://precice.discourse.group/t/installation-of-precice-v2-and-its-openfoam-adapter/171/4 "2020-03-11T07:57:36Z")

</div>

I managed to solve the problems with the installation by following this [tutorial](https://rudhkul.com/posts/fsi_cavity/).  
The thing that I was missing is export the right variables :

```
export PRECICE_ROOT = /path/to/precice/folder 

```

and

```
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export CPATH=$CPATH:/usr/local/include/precice
```

---

<div class="post-metadata">

**Author:** ![dashqua](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/dashqua/32/115_2.png) [@dashqua](https://precice.discourse.group/u/dashqua)\
**Post date:** [July 2, 2020, 2:19pm UTC](https://precice.discourse.group/t/installation-of-precice-v2-and-its-openfoam-adapter/171/6 "2020-07-02T14:19:33Z")

</div>

Hey, it’s me again !  
I decided to reinstall the OF-adapter to have the newest version. I cannot manage to successfully install it. Here are wmake.log and Allwmake.log:  
[wmake.log](https://precice.discourse.group/uploads/short-url/6p0g0z9jDOmOlbwdIIC5OBqNxVw.log) (4.5 KB) [Allwmake.log](https://precice.discourse.group/uploads/short-url/fkA2SE4IkAtuwVdU8pcUjpscVrf.log) (2.0 KB)  
I notice the problem has to do with the **setDeltaT** function that is used with two arguments by the adapter, whereas its implementation in OpenFOAM takes only one argument : [Time.H](https://github.com/OpenFOAM/OpenFOAM-6/blob/master/src/OpenFOAM/db/Time/Time.H).  
Can you help me with this ?

Note: I am using OF-6. I tried using the version of the adapter for OF-6 (which is not updated) and the “latest” (supposedly made for OF-7) and none of them worked.

Edit: A curious thing I noticed: Between [OF-6](https://github.com/precice/openfoam-adapter/blob/OpenFOAM6/Adapter.C) and the [latest](https://github.com/precice/openfoam-adapter/blob/master/Adapter.C) implementation of **Adapter.C** , the call to **setDeltaT** is different: one has this extra argument that upsets the compiler (line 610 approximately).

---

<div class="post-metadata">

**Author:** ![Makis](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/makis/32/25_2.png) [@Makis](https://precice.discourse.group/u/Makis)\
**Post date:** [July 2, 2020, 8:31pm UTC](https://precice.discourse.group/t/installation-of-precice-v2-and-its-openfoam-adapter/171/7 "2020-07-02T20:31:28Z")

</div>

> [@dashqua](#):
>
> I notice the problem has to do with the **setDeltaT** function that is used with two arguments by the adapter, whereas its implementation in OpenFOAM takes only one argument : [Time.H](https://github.com/OpenFOAM/OpenFOAM-6/blob/master/src/OpenFOAM/db/Time/Time.H).  
> Can you help me with this ?

This is exactly the breaking change introduced in OpenFOAM 6 for which we are maintaining a different branch (and working on a solution to not need separate branches). For now, you indeed need to use the branch [`OpenFOAM6`](https://github.com/precice/openfoam-adapter/tree/OpenFOAM6).

> [@dashqua](#):
>
> and the “latest” (supposedly made for OF-7)

By “latest” you are refering I guess to the `master` branch. This is the branch that works with most versions at the moment and occasionally we also update the special cases branches (such as `OpenFOAM6` and `OpenFOAM7`). If you need the updates, please ping us (I just updated them), or just do a `git merge master`.

If you are refering to the branch `OpenFOAM7`, this is supposed to work with OpenFOAM 7, but not with 6, as OpenFOAM 7 also renamed `fileName::DIRECTORY` to `fileType::directory`. In any case (also for future readers), please stick to the instructions in the page [Notes on OpenFOAM](https://github.com/precice/openfoam-adapter/wiki/Notes-on-OpenFOAM), this is the central and most up-to-date resource.

> [@dashqua](#):
>
> The thing that I was missing is export the right variables :
> 
> ```
> export PRECICE_ROOT = /path/to/precice/folder 
> 
> ```
> 
> and
> 
> ```
> export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/lib
> export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
> export CPATH=$CPATH:/usr/local/include/precice
> 
> ```

This really depends how and where you installed preCICE. Since you installed a Debian package, you should not need this, as you have also installed a pkg-config file under `/usr/lib/x86_64-linux-gnu/pkgconfig/`, which is a known system location.

If you have preCICE files in `/usr/local/`, then you probably got them from a previous installation from source, using the default `CMAKE_INSTALL_PREFIX`. If you still have the the build directory available, you can try running `sudo make uninstall` from inside the build directory (preCICE v1.6.0 or newer). Otherwise, you could manually clean previously installed files.

In any case, if you are using Ubuntu & friends, the best is to either get the precompiled packages, or [build them yourself](https://github.com/precice/precice/wiki/Building:-Using-CMake#debian-packages) and install them using your package manager.

In that case:

> [@dashqua](#):
>
> if everything’s fine, should I just use
> 
> `dpkg -i ./libprecice2_2.0.1_bionic.deb`  
> or  
> `apt install ./libprecice2_2.0.1_bionic.deb`  
> ? And do I need to look at something specific before moving to openfoam-adapter ?

prefer using `apt`, as it is more user-friendly. `dpkg` can give you more options, which you normally don’t need.

Does this solve your issue?

---

<div class="post-metadata">

**Author:** ![dashqua](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/dashqua/32/115_2.png) [@dashqua](https://precice.discourse.group/u/dashqua)\
**Post date:** [July 3, 2020, 9:17am UTC](https://precice.discourse.group/t/installation-of-precice-v2-and-its-openfoam-adapter/171/8 "2020-07-03T09:17:12Z")

</div>

Hello @Makis !

Thanks for the technical precisions and the resources.

Just for clarification, My first 3 posts are for a problem I had with the installation from sources, and its resolving (I chose to include the _export_s in my _.bashrc_ at that time). My fourth post has to do with another installation of the same OpenFOAM-adapter and you are right: I should have merged from the _master_ git repo. I am a bit uncomfortable with git when it’s out of its basic use, so I did a fresh install which worked thanks to your post by using the command (make sure OpenFOAM is sourced):

```
git clone --single-branch --branch OpenFOAM6 https://github.com/precice/openfoam-adapter.git
cd openfoam-adapter
./Allclean
./Allwmake

```

I opted for installing for sources because I need to modify the adapter (cf my [other topic](https://precice.discourse.group/t/openfoam-openfoam-fsi-coupling/150/)).

Thanks a lot !

EDIT: Many also thanks for your reactivity to update the branch !

---

<div class="post-metadata">

**Author:** ![Makis](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/makis/32/25_2.png) [@Makis](https://precice.discourse.group/u/Makis)\
**Post date:** [July 3, 2020, 10:20am UTC](https://precice.discourse.group/t/installation-of-precice-v2-and-its-openfoam-adapter/171/9 "2020-07-03T10:20:02Z")

</div>

Don’t worry, @dashqua! We know that Git is not something that our users should be experienced with, I just wrote the details also in case a future reader needs them. 🙂

Feel free to open a different thread for any new problem.
