Skip to content
Advertisement

error while loading shared libraries: libgmock.so: cannot open shared object file: No such file or directory

I am currently facing an issue with a project of mine foudn while configuring CI.

Resume

The problem faced is the following: error while loading shared libraries: libgmock.so: cannot open shared object file: No such file or directory.

For the problem above I am not installing the google test/google mock framework but I am compiling it. Although it says it didn’t foudn I have printed the LD_LIBRARY_PATH variable with the following results:

[root@f2cf44f0b794 st]# echo $LD_LIBRARY_PATH
/st/staging_dir/x86_64-linux-gnu/lib:/st/staging_dir/x86_64-linux-gnu/lib64

To check if the file didn’t really exists I have used find and checked it did exists:

[root@f2cf44f0b794 st]# find . -name libgmock.so*
./build_dir/x86_64-linux-gnu/googletest/googlemock/libgmock.so
./staging_dir/x86_64-linux-gnu/lib64/libgmock.so

I have also ls the dir to double check this:

[root@f2cf44f0b794 st]# ls /st/staging_dir/x86_64-linux-gnu/lib64/
cmake        libcrypto.so      libgmock.so       libgtest.so       libprotobuf-lite.so          libprotobuf.so          libprotoc.so          libssh.so    libssh.so.4.8.1  libssl.so      pkgconfig
libcrypto.a  libcrypto.so.1.1  libgmock_main.so  libgtest_main.so  libprotobuf-lite.so.3.8.0.0  libprotobuf.so.3.8.0.0  libprotoc.so.3.8.0.0  libssh.so.4  libssl.a         libssl.so.1.1

Background

All the code is being built for both Ubuntu 14.04.5 and centos7. For this, two builds are run on two Docker containers with the distributions above. The funny thing is that, for the Ubuntu container, the build doesn’t fail but for CentOS container the build fails with the error above. Although the error above is just for unit testing and I could easily disable them for CentOS build, I really wanted to understand why this issue is happening.

Thanks in advance.

Advertisement

Answer

I found the issue. Everything was set up correctly, except a script that builds the unit tests that were overidding the LD_LIBRARY_PATH. It was working on Ubuntu because the LD_LIBRARY_PATH overriden with was still correct for Ubuntu.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement