【发布时间】:2019-08-28 12:03:44
【问题描述】:
我在使用 CMake 时无法找到链接 czmq 库的方法。我可以使用 gcc myprog.c -lczmq 的 czmq 库编译代码就好了。
我的项目结构如下:
src/...
include/...
build/...
CMakeLists.txt
src/ 文件夹包含.c 文件和相应的.h 文件。 include/ 文件夹包含库头。
我当前的CmakeLists.txt 看起来像这样:
cmake_minimum_required(VERSION 3.10)
project(mylib)
set(CMAKE_BUILD_TYPE Release)
#Header
include_directories(include)
#Src files, GLOB allows for wildcard additions
file(GLOB SOURCES "src/*c")
#Generate the shared library from the sources
add_library(mylib SHARED ${SOURCES})
#Set location for the library installation
install(TARGETS mylib DESTINATION .)
【问题讨论】:
-
那个副本没有回答我的问题,因为当我编译使用创建的库的代码时,我仍然必须添加
-lczmq标志。