CMake链接共享库

时间:2015-06-12 05:20:57

标签: cmake

我正在尝试使用cmake链接共享库。该图书馆位于已知位置/home/username/lib。我已将find_library添加到CMakeLists.txt以查找库。通过运行ccmake我验证了库已正确本地化。但是当我生成makefile并调用make时,我收到错误: /user/bin/ld: cannot find -labc

以下是CMakeList.txt文件:

cmake_minimum_required(VERSION 2.8)
project(application)
find_package( OpenCV REQUIRED )
include_directories("include")
add_executable( application demo.cpp )
find_library(abc abc PATHS /home/username/lib)
target_link_libraries( application abc ${OpenCV_LIBS})

我做错了什么?

1 个答案:

答案 0 :(得分:2)

find_library的第一个参数是变量。因此,您应该使用target_link_libraries

中创建和填充变量的值
target_link_libraries( application ${abc} ${OpenCV_LIBS})