我正在尝试使用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})
我做错了什么?
答案 0 :(得分:2)
find_library
的第一个参数是变量。因此,您应该使用target_link_libraries
:
target_link_libraries( application ${abc} ${OpenCV_LIBS})