barbagroup/PetIBM

libpetibmapps.so.0: cannot open shared object file: No such file or directory

shi-guangyu opened this issue · 4 comments

Hi, guys,

I'm trying to implement my new applications as suggested in issue#149. I use the source code from this repo as a start https://github.com/mesnardo/petibm-flapping. I just updated the Makefile according to my PetIBM installation and instructions from Use PetIBM API.

However, I was able to compile and build the code, but when I tried to run, it gave the following error:

./petibm_flapping: error while loading shared libraries: libpetibmapps.so.0: cannot open shared object file: No such file or directory

But, I'm sure that the libpetibmapps.so.0 is under this directory: $PETIBM_INSTALL/lib.

I'm attaching all the files for your reference. BTW, I have exported $PETSC_DIR $PETSC_ARCH $PETIBM_DIR and $PETIBM_INSTALL in my ~/.bashrc file. So they are not exported again in the Makefile.
petibm_flapping.zip

Can you guys give some clues what could be possibly wrong?

Many thanks.

Guangyu

Hi, it's probably due to that the OS did not know where to find libpetibmapps.so.0. The fasted solution is to set the environment variable LD_LIBRARY_PATH to $PETIBM_INSTALL/lib. For most Linux distributions, you can execute export LD_LIBRARY_PATH=$PETIBM_INSTALL/lib:$LD_LIBRARY_PATH in the same terminal before you start the simulation.

But I have included the $PETIBM_INSTALL/lib in the Makefile. Or the Makefile only builds the static libs?

You only include -L$PETIBM_INSTALL/lib in LDFLAGS, which only allows the compiler to find the libraries during compilation and linking time. Once you finished compilation and linking, it forgets the information of the library location. So you will need to also include the library directory with -Wl,-rpath,<path> flags. For example, see line 5 in this Makefile.

In this way, the resulting solver can remember where to find libraries.

Alright, I see. I was wondering what those flags are used for.

Thank you so much!

Best wishes;

Guangyu