如果使用cmake存在多个副本,则将自定义共享库链接到二进制文件

时间:2016-08-06 18:35:00

标签: ubuntu cmake

我将本地libssl.so和libcrypto.so文件链接到ubuntu环境中的二进制文件。我在项目文件夹#yourbutton:hover { background: linear-gradient: ....; } 中有这些.so文件。 路径${CMAKE_LIBRARY_PATH}中存在的相同文件也是之前安装的。

但是在编译之后,我在二进制文件上做了ldd。但它始终显示" / lib / x86_64-linux-gnu /"作为链接路径。

"/lib/x86_64-linux-gnu/"

CMakeList.txt

ldd rtcc
linux-vdso.so.1 =>  (0x00007ffdf36b6000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f91ce927000)
libboost_system.so.1.54.0 => /usr/lib/x86_64-linux-gnu/libboost_system.so.1.54.0 (0x00007f91ce723000)
libssl.so.1.0.0 => /lib/x86_64-linux-gnu/libssl.so.1.0.0 (0x00007f91ce440000)
libcrypto.so.1.0.0 => /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (0x00007f91ce130000)

我需要链接项目中存在的共享对象。你能帮我解决一下这个问题。

经过一些建议: CMakefile.txt

SET(CMAKE_LIBRARY_PATH ${RTCC_SOURCE_DIR}/libs)
find_library(SSL_LIB NAMES "libssl.so" PATHS ${CMAKE_LIBRARY_PATH})
find_library(CRYPTO_LIB NAMES "libcrypto.so" PATHS ${CMAKE_LIBRARY_PATH})

#Tried with NO_DEFAULT_PATH also, but didn't work
#find_library(SSL_LIB NAMES "libssl.so" PATHS ${CMAKE_LIBRARY_PATH} NO_DEFAULT_PATH)
#find_library(CRYPTO_LIB NAMES "libcrypto.so" PATHS ${CMAKE_LIBRARY_PATH} NO_DEFAULT_PATH)

target_link_libraries (rtcc
    ${Boost_LIBRARIES}
    ${SSL_LIB}
    ${CRYPTO_LIB}
)

install(TARGETS rtcc DESTINATION bin
    PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)

0 个答案:

没有答案