1
votes

I am trying to link my library and opencv library. Cmake is working properly, solution is build but linker error occurs. It seems as cmake couldnt link opencv lib with my library.

This is an error which visual studio has.

CMakeLists configuration for opencv lib

This is piece of CMakeLists conf responsible for linking libs.

# link libs
target_link_libraries(${APP_NAME} ${OpenCV_LIBS})

I would be very grateful for you help.

1

1 Answers

0
votes

CMakeLists.txt I use for OpenCV apps configuring.

cmake_minimum_required(VERSION 2.8)
set (PROJ_NAME YourAppName)
project(${PROJ_NAME})
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/build)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})

FIND_PACKAGE(OpenCV)

set(folder_source   main.cpp
                    )

set(folder_header   main.h
                    )

SOURCE_GROUP("Source Files" FILES ${folder_source})
SOURCE_GROUP("Header Files" FILES ${folder_header})
ADD_EXECUTABLE(${PROJ_NAME} ${folder_source} ${folder_header})
TARGET_LINK_LIBRARIES(${PROJ_NAME} ${OpenCV_LIBS} )

it works fine, but check your opencv path does not contain spaces

(it does not like paths like "C:/Documents/Visual Studio 2015/Projects/opencv_build").