# Cannot find -lprecice and precice/SolverInterface.hpp

**URL:** <https://precice.discourse.group/t/cannot-find-lprecice-and-precice-solverinterface-hpp/384>\
**Category:** Installing preCICE\
**Tags:** python, linking\
**Created:** [November 8, 2020, 6:53pm UTC](https://precice.discourse.group/t/cannot-find-lprecice-and-precice-solverinterface-hpp/384 "2020-11-08T18:53:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jun\_leng](https://avatars.discourse-cdn.com/v4/letter/j/c89c15/32.png) [@jun\_leng](https://precice.discourse.group/u/jun_leng)\
**Post date:** [November 8, 2020, 6:53pm UTC](https://precice.discourse.group/t/cannot-find-lprecice-and-precice-solverinterface-hpp/384/1 "2020-11-08T18:53:49Z")

</div>

Hi everyone,

I met a problem when I built python\_future binding using:

> [lengjun@localhost python\_future]$ python setup.py install --user

I had added related environmental variables already in my ~/.bashrc as follows and source it before I built it:

> #===precice1.6.1======  
> export PKG\_CONFIG\_PATH=/home/lengjun/softwares/precice-1.6.1/build/precice\_install\_leng/lib/pkgconfig  
> export LD\_LIBRARY\_PATH=/home/lengjun/softwares/precice-1.6.1/build/precice\_install\_leng/lib:$LD\_LIBRARY\_PATH  
> #export CMAKE\_PREFIX\_PATH=/home/lengjun/softwares/precice-1.6.1/build/precice\_install\_leng  
> export PATH=/home/lengjun/softwares/precice-1.6.1/build/precice\_install\_leng:$PATH  
> export PATH=/home/lengjun/softwares/precice-1.6.1/build/precice\_install\_leng/include:$PATH  
> export LD\_LIBRARY\_PATH=/home/lengjun/softwares/precice-1.6.1/build:$LD\_LIBRARY\_PATH

The error is:

> fatal error: precice/SolverInterface.hpp: No such file or directory  
> #include “precice/SolverInterface.hpp”  
> ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
> compilation terminated.

So I copied precice/SolverInterface.hpp to python\_future but another error occurred:

> /opt/rh/devtoolset-8/root/usr/libexec/gcc/x86\_64-redhat-linux/8/ld: cannot find -lprecice  
> collect2: error: ld returned 1 exit status  
> error: command ‘g++’ failed with exit status 1

But libprecice.so can be found when I use `locate` command.

> [lengjun@localhost python\_future]$ locate precice.so  
> /home/lengjun/softwares/precice-1.6.1/build/libprecice.so
> 
> /home/lengjun/softwares/precice-1.6.1/build/libprecice.so.1.6.1  
> /home/lengjun/softwares/precice-1.6.1/build/precice\_install\_leng/lib/libprecice.so
> 
> /home/lengjun/softwares/precice-1.6.1/build/precice\_install\_leng/lib/libprecice.so.1.6.1
> 
> /home/lengjun/softwares/precice-1.6.1/tools/packaging/Ubuntu\_18.04/debian/usr/lib/x86\_64-linux-gnu/libprecice.so
> 
> /home/lengjun/softwares/precice-1.6.1/tools/packaging/Ubuntu\_18.04/debian/usr/lib/x86\_64-linux-gnu/libprecice.so.1.1
> 
> /home/lengjun/softwares/precice-1.6.1/tools/packaging/Ubuntu\_18.04/debian/usr/lib/x86\_64-linux-gnu/libprecice.so.1.1.1

System information:  
centOS 7  
preCICE 1.6.1

I don’t know why.

Best regards,  
Jun

---

<div class="post-metadata">

**Author:** ![ajaust](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ajaust/32/160_2.png) [@ajaust](https://precice.discourse.group/u/ajaust)\
**Post date:** [November 9, 2020, 9:09am UTC](https://precice.discourse.group/t/cannot-find-lprecice-and-precice-solverinterface-hpp/384/2 "2020-11-09T09:09:20Z")

</div>

Hi Jun,

Could you check if you have a subdirectory called `include/` in your preCICE installation?

- If yes, try setting the environment variable `CPATH` to this directory.
- If you do not have this subdirectory, could you give more information on how you installed preCICE? Did you install it from source and did you run `make install`?

As a side note: Do you require preCICE 1.6.1? It is quite old so maybe it would also make sense to start with a current version of preCICE.

**Edit**  
Just as a further addtion: The `setup.py` of the python bindings got the options `--include-dirs` and `--library-dirs` that you can use in order to point it to the directory including the include files and the library of your preCICE installation. I am not sure when (in terms of which version of the bindings) these options where introduced, but you could also check if this works instead of setting the `CPATH` environment variable.

Best,  
Alex

---

<div class="post-metadata">

**Author:** ![jun\_leng](https://avatars.discourse-cdn.com/v4/letter/j/c89c15/32.png) [@jun\_leng](https://precice.discourse.group/u/jun_leng)\
**Post date:** [November 9, 2020, 8:28pm UTC](https://precice.discourse.group/t/cannot-find-lprecice-and-precice-solverinterface-hpp/384/3 "2020-11-09T20:28:50Z")

</div>

Hi Alex,

Thank you for your help!

I do have the subdirectory called include/precice which contains some head files. Adding `CPATH` solved the problem of SOlverInterface.hpp.

Then I added `-Lpath/to/lib/precice` to setup.py and the problem of -lprecice was solved.

By the way, are there any changes needed to do in adapters and other input files to adapt to different versions of preCICE? I need to keep the same version and results in my laptop and the high-performance computer.

Best regards,  
Jun

---

<div class="post-metadata">

**Author:** ![ajaust](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ajaust/32/160_2.png) [@ajaust](https://precice.discourse.group/u/ajaust)\
**Post date:** [November 9, 2020, 9:49pm UTC](https://precice.discourse.group/t/cannot-find-lprecice-and-precice-solverinterface-hpp/384/4 "2020-11-09T21:49:02Z")

</div>

Regarding changes to the adapter I am not sure. The interface to the Python-bindings have changed a bit recently, but I think the `precice_future` API is the current state. The package Python module changed its name though.

With regard to the preCICE configuration files: Configuration files for preCICE 1.X.X are compatible with any 1.X.X version as far as I know. The configuration files of all preCICE 2.X.X versions are compatible with each other. Configuration files of preCICE 1.X.X are not compatible with preCICE 1.X.X, but the changes are rather small.

---

<div class="post-metadata">

**Author:** ![jun\_leng](https://avatars.discourse-cdn.com/v4/letter/j/c89c15/32.png) [@jun\_leng](https://precice.discourse.group/u/jun_leng)\
**Post date:** [November 10, 2020, 1:40am UTC](https://precice.discourse.group/t/cannot-find-lprecice-and-precice-solverinterface-hpp/384/5 "2020-11-10T01:40:32Z")

</div>

OK, thank you, Alex! I will have a try.

---

<div class="post-metadata">

**Author:** ![ajaust](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/ajaust/32/160_2.png) [@ajaust](https://precice.discourse.group/u/ajaust)\
**Post date:** [November 10, 2020, 9:13am UTC](https://precice.discourse.group/t/cannot-find-lprecice-and-precice-solverinterface-hpp/384/6 "2020-11-10T09:13:51Z")

</div>

Hope it works out!

If you want to upgrade from preCICE 1.X.X to 2.X.X, I have written the bash script below some time ago to upgrade my configurations. Maybe this helps you, but it does not come with any guarantees. 😉

```
#!/usr/bin/env bash

# GNU LGPL v3
# Copyright 2020 Alexander Jaust
# alexander.jaust@ipvs.uni-stuttgart.de
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.

# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

replace_string() {
  local search="${1}"
  local replace="${2}"
  local filename="${3}"
  sed -i "s/${search}/${replace}/g" "$filename"
}

for f in `ls *.xml`; do
  echo $f

  cp "$f" "${f}_bak"
  
  # replace strings
  replace_string "mapping:petrbf" "mapping:rbf" $f
  
  replace_string "timestep-length" "time-window-size" $f
  replace_string "max-timestep" "max-time-windows" $f
  
  replace_string "post-processing" "acceleration" $f
  replace_string "timesteps-reused" "time-windows-reused" $f
  replace_string "reused-timesteps-at-restart" "reused-time-windows-at-restart" $f

  replace_string "timestep-interval" "every-n-time-windows" $f
  replace_string "on-timestep-complete-post" "on-time-window-complete-post" $f
done

```

---

<div class="post-metadata">

**Author:** ![uekerman](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/uekerman/32/2199_2.png) [@uekerman](https://precice.discourse.group/u/uekerman)\
**Post date:** [November 10, 2020, 12:51pm UTC](https://precice.discourse.group/t/cannot-find-lprecice-and-precice-solverinterface-hpp/384/7 "2020-11-10T12:51:04Z")

</div>

There is also an upgrade guide here: [https://github.com/precice/precice/wiki/Porting-adapters-from-preCICE-1.x-to-2.x](https://github.com/precice/precice/wiki/Porting-adapters-from-preCICE-1.x-to-2.x)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/precice/original/1X/67d2a5fa6f80e597e2267ff17fa8c1673cd11caa.svg) [@system](https://precice.discourse.group/u/system)\
**Post date:** [November 13, 2020, 12:51pm UTC](https://precice.discourse.group/t/cannot-find-lprecice-and-precice-solverinterface-hpp/384/8 "2020-11-13T12:51:06Z")

</div>

Closed on November 13, 2020, 12:51pm UTC

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
