Cannot find -lprecice and precice/SolverInterface.hpp

Hi everyone,

I met a problem when I built python_future binding using:

[lengjun@localhost python_future]$ python install --user

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

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 can be found when I use locate command.

[lengjun@localhost python_future]$ locate






System information:
centOS 7
preCICE 1.6.1

I don’t know why.

Best regards,

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.

Just as a further addtion: The 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.


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 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,

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.

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

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. :wink:

#!/usr/bin/env bash

# Copyright 2020 Alexander Jaust
# 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
# 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

There is also an upgrade guide here:

1 Like

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