Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using OpenCv with CLion

Tags:

c++

opencv

clion

Hey im trying to use the OpenCV Lib on elementary OS (based on Ubuntu).

I followed this tutorial:

https://www.youtube.com/watch?v=i1K9rXiei9I

I added this lines to the CmakeList.txt:

find_package(OpenCV REQUIRED)

include_directories(${OpenCV_INCLUDE_DIRS})
target_link_libraries(myOpenCVTest ${OpenCV_LIBS})

But when i build the project it fails with some errors like:

/usr/bin/ld: cannot find -lopencv_core
...

Can anyone help me???

like image 953
johni07 Avatar asked Apr 13 '16 07:04

johni07


1 Answers

I solved the problem.

First I deleted all old OpenCV files and installations.

After that I followed this guide to install OpenCV and all required packages.

And now everything is working with this CmakeList.txt:

cmake_minimum_required(VERSION 2.8.4)
project(OpenCVTest)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

find_package( OpenCV REQUIRED )
set(SOURCE_FILES main.cpp)
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
include_directories(${OpenCV_INCLUDE_DIRS})
target_link_libraries( ${PROJECT_NAME} ${OpenCV_LIBS} )
like image 111
johni07 Avatar answered Sep 22 '22 12:09

johni07