【发布时间】:2016-06-15 21:36:35
【问题描述】:
我有两个 cmake 项目:
BiosPatcher\CommonBase\
BiosPatcher\Bios\
第一个构建一个库并具有带有标题的 ./include 文件夹。 如何构建依赖于第一个库 ./include 进行编译和 libCommonBase.dll 执行的第二个项目库(或可执行文件)。
我已经包含了类似的头文件
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../CommonBase/include)
而且它有效。
我像这样链接库:
target_link_libraries (Bios libCommonBase)
但我收到错误消息:
c:\Users\Sakhno\workspace\BiosPatcher\Bios\build>make
[ 16%] Linking CXX shared library libBios.dll
C:/mingw-w64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -llibCommonBase
collect2.exe: error: ld returned 1 exit status
我想我需要以某种方式指定文件夹来查找库,但我不知道如何。
【问题讨论】:
-
至少我需要如何正确包含标题
-
使用命令include_directories 设置包含目录和target_link_libraries 链接库有什么问题?
-
分享您的研究对每个人都有帮助。请告诉我们您尝试了什么以及为什么它不能满足您的需求。这表明您已经花时间尝试帮助自己,它使我们免于重复明显的答案,最重要的是它可以帮助您获得更具体和相关的答案!另见how to ask
-
感谢您的澄清。如果您不是通过
add_subdirectory()添加其他项目,那么以下问题之一会有所帮助吗? Making cmake library accessible by other cmake packages automatically(搜索其他项目)或How to instruct CMake to use the build architecture compiler?(从外部注入其他项目的构建路径)。
标签: cmake dependencies project