Ask Your Question
0

How to compile opencv project in cmake [closed]

asked 2017-01-28 06:33:38 -0600

agatte gravatar image

Hello,

I am working on Windows and I have already compiled opencv 3.2 in cmake on MS Visual Studio 2010. Now I want to make a test a create small project example. But I don"t know how should look like CMakeLists. I want to compile OpenCv example code in *.cpp file with cmake.

Could anyone help me please ?

  cmake_minimum_required(VERSION 2.8) 

PROJECT (TestOpenCV)
find_package(OpenCV REQUIRED)

add_executable(test1 test1.cpp)
target_link_libraries(test1 OpenCV ${OpenCV_LIBS})

link_directories(${OpenCV_LIB_DIR})

I got an link error concerning OpenCV.lib ?

I think that it is missing something in this script.

I would be appreciate for any help please

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by LBerger
close date 2017-01-29 05:19:06.372711

Comments

Now it is working :) Thanks for good hints :)

cmake_minimum_required(VERSION 2.8)

PROJECT (TestOpenCV)
find_package(OpenCV REQUIRED)

add_executable(test1 test1.cpp)
target_link_libraries(test1 ${OpenCV_LIBS}`)`
agatte gravatar imageagatte ( 2017-01-29 03:48:27 -0600 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2017-01-28 08:16:46 -0600

LBerger gravatar image

I don't think you need last line link_directories(${OpenCV_LIB_DIR}) Can you give link error?

Have you give good OpenCV_DIR in cmake GUI (path where you have vs 2010 sln)?

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-01-28 06:33:38 -0600

Seen: 277 times

Last updated: Jan 28 '17