Ekalic
Ekalic

Reputation: 703

CMake link shared library

I am trying to link shared library using cmake. The library is located at known location /home/username/lib. I have added find_library to CMakeLists.txt to find the library. By running ccmake I verified that the library was correctly localized. But when I generate makefile and call make I get error: /user/bin/ld: cannot find -labc

Here is the CMakeList.txt file:

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})

What I am doing wrong?

Upvotes: 1

Views: 264

Answers (1)

ixSci
ixSci

Reputation: 13708

The first parameter to find_library is a variable. So you should use the value of that created and filled out variable in the target_link_libraries:

target_link_libraries( application ${abc} ${OpenCV_LIBS})

Upvotes: 2

Related Questions