Linking problems with preCICE and my own solver based on deal.II

Hello everyone,

I installed preCICE using the binary package. Specifically, I downloaded this one from github:

https://github.com/precice/precice/releases/download/v3.1.2/libprecice3_3.1.2_bookworm.deb

I then ran

sudo apt install ./libprecice3_3.1.2_bookworm.deb

Now I am trying to run a simulation and I need to edit the CMakeLists.txt of my solver to add the lin to the preCICE libraries. I then added these lines which I also found inside the CMakeLists.txt of the deal.ii adapter:

FIND_PACKAGE(preCICE 3.1.2 REQUIRED
  HINTS ${PRECODE_DIR}
  )
MESSAGE(STATUS ‘Using the preCICE version found at ${precice_CONFIG}’)

TARGET_LINK_LIBRARIES(${TARGET} preCICE::preCICE)

At this point, when I launch the ‘cmake ..’ command, everything is executed correctly. However, when I give the ‘make’ command I get the following error:

make -j8
[ 25%] Building CXX object CMakeFiles/wingBEM-lib.g.dir/source/computational_domain_wing.cc.o
[ 25%] Building CXX object CMakeFiles/wingBEM-lib.g.dir/source/bem_problem_wing.cc.o
[ 25%] Building CXX object CMakeFiles/wingBEM-lib.dir/source/boundary_conditions_wing.cc.o
[ 25%] Building CXX object CMakeFiles/wingBEM-lib.g.dir/source/boundary_conditions_wing.cc.o
[ 31%] Building CXX object CMakeFiles/wingBEM-lib.dir/source/computational_domain_wing.cc.o
[ 37%] Building CXX object CMakeFiles/wingBEM-lib.dir/source/bem_problem_wing.cc.o
[ 50%] Building CXX object CMakeFiles/wingBEM-lib.g.dir/source/driver.cc.o
[ 50%] Building CXX object CMakeFiles/wingBEM-lib.dir/source/driver.cc.o
[ 56%] Building CXX object CMakeFiles/wingBEM-lib.g.dir/source/precice_adaptor.cc.o
[ 62%] Building CXX object CMakeFiles/wingBEM-lib.dir/source/precice_adaptor.cc.o
[ 68%] Linking CXX shared library libwingBEM-lib.so
[ 75%] Linking CXX shared library libwingBEM-lib.g.so
[ 75%] Built target wingBEM-lib
[ 81%] Building CXX object CMakeFiles/wingBEM.dir/source/main.cc.o
[ 81%] Built target wingBEM-lib.g
[ 87%] Building CXX object CMakeFiles/wingBEM.g.dir/source/main.cc.o
[ 93%] Linking CXX executable wingBEM
[ 93%] Built target wingBEM
[100%] Linking CXX executable wingBEM.g
libwingBEM-lib.g.so: error: undefined reference to 'precice::Participant::Participant(precice::span<char const, 18446744073709551615ul>, precice::span<char const, 18446744073709551615ul>, int, int)'
libwingBEM-lib.g.so: error: undefined reference to 'precice::Participant::~Participant()'
libwingBEM-lib.g.so: error: undefined reference to 'precice::Participant::initialize()'
libwingBEM-lib.g.so: error: undefined reference to 'precice::Participant::getMeshVertexSize(precice::span<char const, 18446744073709551615ul>) const'
libwingBEM-lib.g.so: error: undefined reference to 'precice::Participant::getMaxTimeStepSize() const'
libwingBEM-lib.g.so: error: undefined reference to 'precice::Participant::readData(precice::span<char const, 18446744073709551615ul>, precice::span<char const, 18446744073709551615ul>, precice::span<int const, 18446744073709551615ul>, double, precice::span<double, 18446744073709551615ul>) const'
libwingBEM-lib.g.so: error: undefined reference to 'precice::Participant::advance(double)'
libwingBEM-lib.g.so: error: undefined reference to 'precice::Participant::isCouplingOngoing() const'
libwingBEM-lib.g.so: error: undefined reference to 'precice::Participant::finalize()'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/wingBEM.g.dir/build.make:209: wingBEM.g] Errore 1
make[1]: *** [CMakeFiles/Makefile2:193: CMakeFiles/wingBEM.g.dir/all] Errore 2
make: *** [Makefile:101: all] Errore 2

I think that the problem could regard the preCICE libraries, but I really don’t know how to solve it.

Thank you in advance,
Luca

Hi @lucacattarossi,

The lines in the adapter are

I think capitalization makes a difference here and CMake should complain in your case, that it does not find the package preCICE as the actual package name is precice. A bit surprising that you only see this at link time though. What’s the output you get when running cmake in the first place?

Hello, David.
Thank you for your reply. I finally solved it.

No, it was actually my mistake to write that piece of code here on the forum. Those capitalisation errors were not really there inside my CMakeLists.txt file. I had taken and copied those lines of code exactly from the deal.II adaptor.
At the end of the day, I think the problem had to do with a misplacement of the call to the precice libraries within the file.

Now it seems to compile correctly without any errors or warnings.

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