【发布时间】:2017-07-30 11:13:07
【问题描述】:
我对@987654321@ 比较陌生,我开发了一个小项目,该项目构建了一个链接到共享库的库,名为external_library。我的CMakeLists.txt 文件看起来像这样:
cmake_minimum_required(VERSION 2.8.12)
project(project_name)
include_directories(path_to_external_library_source_code)
add_subdirectory(path_to_external_library_header_files subproject/external_library)
target_link_libraries(project_name external_library)
install(TARGETS project_name DESTINATION installation_path)
当我构建项目时(使用make),它运行良好,并且正确创建了链接(我已经使用ldd 命令检查了它)。但是,当我尝试安装它时(使用make install),安装路径中生成的文件未链接到指定的共享库。
再次使用ldd,我检查了安装路径中生成的库没有找到共享库,尽管在构建路径中生成的库中找到了。我该如何解决这个问题?
谢谢。
Pd:我在Ubuntu 16.04.2 LTS 中使用CMake 3.5.1。
【问题讨论】:
-
您认为
add_subdirectory(path_to_external_library_header_files subproject/external_library)会做什么?path_to_external_library_header_files中是否有 CMakeLists.txt 文件?你为什么要把外部库作为你项目的一部分? -
是的,
path_to_external_library_header_files中有一个CMakeLists.txt,它将共享库的.cpp和.h文件添加到项目中。 -
我希望共享库成为创建库的一部分,这就是我使用
add_subdirectory的原因(我希望我做得对)。