OpenFOAM adapter: preCICE as a static or as a shared library?

Hello,
I took every one of your advice from our last discussion and re did the whole thing. There were no errors this time although I got this.

As I am a new use I couldn’t attach my ldd.log file here. Please find it in the drive link here

From the documentation I realize that that I used preCICE as a static library, but I didn’t specify its dependencies correctly.
I found it in https://github.com/precice/openfoam-adapter/wiki/Building Step 5, Bullet Point 3.

I’d like to know whether to use static library or not.
My aim is to conduct FSI simulations utilising CalculiX and OpenFoam.
If I have to use it as a static library, how do I specify the dependencies correctly?

If I shouldn’t use it as a static library, what else should I use it as? How do I build it?

P.S. I am almost there. Thanks for all the help until now.

I edited the title of your post to better describe the actual question: does one need to use preCICE as a static library (Linux: libprecice.a) or as a shared library (libprecice.so)?

Short answer: Shared library is enough and is preferred.

Long answer: You can use both, but keep in mind that:

  • With our default recommendation, preCICE CMake only builds the shared library
  • Some linkers in some cases prefer static libraries over shared libraries. If you have both in the same path and in the same name (just different extension), you may get your code linked to the static library by default. This could be complicated, as you would need to also link to the dependencies of preCICE. If you have both without needing the static library, it would be easier to just delete it.
  • Even if you use preCICE as a shared library and the linker can find it (no problems in wmake.log), the runtime linker also needs to be able to find it. For this reason you need (when you don’t have preCICE installed in a directory known to the linker) to set your LD_LIBRARY_PATH.

In your case, the error has nothing to do with using preCICE as a static library (you actually use it as a shared library and this I get from your ldd.log, where I see that it is looking for libprecice.so.1.6.1, but it cannot find it:

libprecice.so.1.6.1 => not found
It is the follwed by a long list of undefined symbols related to precice::SolverInterface:
undefined symbol: _ZN7precice15SolverInterface24setMeshTriangleWithEdgesEiiii	(/home/nithin/OpenFOAM/nithin-7/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZNK7precice15SolverInterface18isTimestepCompleteEv	(/home/nithin/OpenFOAM/nithin-7/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZNK7precice15SolverInterface19isReadDataAvailableEv	(/home/nithin/OpenFOAM/nithin-7/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZN7precice15SolverInterface20writeBlockScalarDataEiiPKiPKd	(/home/nithin/OpenFOAM/nithin-7/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZN7precice9constants22actionWriteInitialDataB5cxx11Ev	(/home/nithin/OpenFOAM/nithin-7/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZN7precice9constants30actionWriteIterationCheckpointB5cxx11Ev	(/home/nithin/OpenFOAM/nithin-7/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZN7precice15SolverInterfaceC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEii	(/home/nithin/OpenFOAM/nithin-7/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZNK7precice15SolverInterface19readBlockScalarDataEiiPKiPd	(/home/nithin/OpenFOAM/nithin-7/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZNK7precice15SolverInterface9getMeshIDERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE	(/home/nithin/OpenFOAM/nithin-7/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZNK7precice15SolverInterface17isCouplingOngoingEv	(/home/nithin/OpenFOAM/nithin-7/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZN7precice15SolverInterface14initializeDataEv	(/home/nithin/OpenFOAM/nithin-7/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZNK7precice15SolverInterface19readBlockVectorDataEiiPKiPd	(/home/nithin/OpenFOAM/nithin-7/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZN7precice15SolverInterface15setMeshVerticesEiiPKdPi	(/home/nithin/OpenFOAM/nithin-7/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZN7precice15SolverInterface15fulfilledActionERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE	(/home/nithin/OpenFOAM/nithin-7/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZN7precice15SolverInterfaceD1Ev	(/home/nithin/OpenFOAM/nithin-7/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZNK7precice15SolverInterface16isActionRequiredERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE	(/home/nithin/OpenFOAM/nithin-7/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZN7precice15SolverInterface9configureERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE	(/home/nithin/OpenFOAM/nithin-7/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZN7precice15SolverInterface20writeBlockVectorDataEiiPKiPKd	(/home/nithin/OpenFOAM/nithin-7/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZN7precice9constants29actionReadIterationCheckpointB5cxx11Ev	(/home/nithin/OpenFOAM/nithin-7/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZN7precice15SolverInterface10initializeEv	(/home/nithin/OpenFOAM/nithin-7/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZNK7precice15SolverInterface13getDimensionsEv	(/home/nithin/OpenFOAM/nithin-7/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZNK7precice15SolverInterface29getMeshVertexIDsFromPositionsEiiPKdPi	(/home/nithin/OpenFOAM/nithin-7/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZN7precice15SolverInterface7advanceEd	(/home/nithin/OpenFOAM/nithin-7/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZN7precice15SolverInterface8finalizeEv	(/home/nithin/OpenFOAM/nithin-7/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZNK7precice15SolverInterface9getDataIDERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi	(/home/nithin/OpenFOAM/nithin-7/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)

As I see in your Allwmake output, preCICE is not in your LD_LIBRARY_PATH. Where have you installed it? This is a common problem, as I explained before: libprecice cannot be found (at runtime).

Maybe irrelevant, but in your Allwmake output I also see:

ADAPTER_PKG_CONFIG_CFLAGS = -I/usr/local/include

I don’t understand why you have your PKG_CONFIG_PATH (which is where this is extracted from) set to /usr/local/include, while you have preCICE installed in your home directory (from the previous discussion).

Sorry for the late reply…
I’d really like to thank you for all the time and efforts you put into replying my topics.
All credit to you, I was successfully able to run my first FSI simulation.
I was perplexed at the start of my project whether to opt for opensource solvers or commercial software.
After the amount of support I received from this community, I am switching to opensource for every one of my needs.
Lastly, thanks for developing preCICE itself.
I shall definitely try to contribute whatever I can to the discussions in this forum.
And obviously, I’ll be sure to add citations in whatever humble work I wish to produce.
Thank you.

3 Likes

Thank you very much for your kind words, @nithinadidela, your comment made my day! :grin:

The community contributing here would be crucial, as we want to help users help themselves (and each other). We hope that the discussions here serve as self-learning material.

When you get results, we would be happy to showcase your work in our Testimonials page.