Library not found on execution, after compiling using cmake

Viewed 178

I am using cmake in my project.

The CMakeLists.txt code is:

set( GS7_INCLUDE_DIRS "${EXTERNAL_PATH}/ds_sdk/SDK_GS7.0/include" CACHE PATH "SDK GS7.0 include directory" )
set( GS7_LIBRARIES "${EXTERNAL_PATH}/ds_sdk/SDK_GS7.0/lib/linux/x64/gcc49/libdsDriverGCC49.so" "${EXTERNAL_PATH}/ds_sdk/SDK_GS7.0/lib/linux/x64/gcc49/libdsUtilGCC49.so" CACHE FILEPATH "SDK GS7.0 libdsDriver full path" )
...
add_executable( FxLibLoader ... )
...
target_link_libraries( FxLibLoader
  "${GS7_LIBRARIES}"
  ...
)

When I exec cmake --build, the final linking command is

c++ -g CMakeFiles/FxLibLoader.dir/FxLibLoader.cpp.o CMakeFiles/FxLibLoader.dir/FxLogger.cpp.o CMakeFiles/FxLibLoader.dir/mtoProto.pb.cc.o CMakeFiles/FxLibLoader.dir/Stats.cpp.o -o FxLibLoader -L/mnt/e/Desarrollo/sandbox_MTO/externalLibs/ds_sdk/SDK_GS7.0/lib/linux/x64/gcc49 -Wl,-rpath,/mnt/e/Desarrollo/PYMX_II/Mto/MtoApi/debug:/mnt/e/Desarrollo/sandbox_MTO/externalLibs/protobuf/protobuf-3.10.1/linux/lib/x64:/mnt/e/Desarrollo/sandbox_MTO/externalLibs/Hazelcast/linux/lib/x64:/mnt/e/Desarrollo/sandbox_MTO/externalLibs/ds_sdk/SDK_GS7.0/lib/linux/x64/gcc49 /mnt/e/Desarrollo/PYMX_II/Mto/MtoApi/debug/libMtoApi_d.so /mnt/e/Desarrollo/sandbox_MTO/externalLibs/protobuf/protobuf-3.10.1/linux/lib/x64/libprotobuf.so /usr/lib/x86_64-linux-gnu/libpython2.7.so -ldl /mnt/e/Desarrollo/sandbox_MTO/externalLibs/Hazelcast/linux/lib/x64/libHazelcastClient3.12_64.so -ldsDriverGCC49 -ldsUtilGCC49 -lstdc++fs

Where the link options are good. The compilation and linking is done without errors, but when I do

>ldd FxLibLoader | fgrep found

libdsUtilGCC49.so => not found

However, the libdsDriverGCC49.so library, which is in the same directory as the missing ... It's found !

Also, if I do

LD_LIBRARY_PATH='/mnt/e/Desarrollo/sandbox_MTO/externalLibs/ds_sdk/SDK_GS7.0/lib/linux/x64/gcc49' ldd FxLibLoader | fgrep found

I get empty result, all libraries are located !

  • What am I doing wrong?
  • How do I solve it ?
1 Answers

What am I doing wrong?

You expect the linker to search for libraries in /mnt/e/Desarrollo/sandbox_MTO/externalLibs/ds_sdk/SDK_GS7.0/lib/linux/x64/gcc49 directory, while the linker does not.

How do I solve it ?

Instruct the linker to search in that directory for the library, or copy the library to one of directories already searched by the linker. See man ld for more info. You may want to interest yourself in -rpath.

Related