Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hello. As per your question, I guess that you have installed OpenCV but are having problem while compiling and running the code. Here are steps you should follow. 1. Name your .cpp file as main.cpp 2. Create a .txt file and name it as CMakeLists.txt 3. In the CmakeLists.txt file paste the following lines

" cmake_minimum_required(VERSION 2.6) cmake_policy(SET CMP0012 NEW) PROJECT(project)

Requires OpenCV

FIND_PACKAGE(OpenCV 3.0.0 REQUIRED) MESSAGE("OpenCV version : ${OpenCV_VERSION}")

include_directories(${OpenCV_INCLUDE_DIRS}) link_directories(${OpenCV_LIB_DIR}) ADD_EXECUTABLE(app main.cpp) TARGET_LINK_LIBRARIES(app ${OpenCV_LIBS}) " without the doublequotes at the start and the end. Save the file.

  1. Now open the terminal and go to the directory where these file are stored. And in the terminal type "cmake ." ,without the doublequotes.
  2. Now in the terminal type "make" and press enter.
  3. It will compile and generate an executable file name app
  4. Execute the app file using ./app
  5. Hope it helps.

Hello. As per your question, I guess that you have installed OpenCV but are having problem while compiling and running the code. Here are steps you should follow. 1. Name your .cpp file as main.cpp 2. Create a .txt file and name it as CMakeLists.txt 3. In the CmakeLists.txt file paste the following lineslines

" cmake_minimum_required(VERSION 2.6) cmake_policy(SET CMP0012 NEW) PROJECT(project)

Requires OpenCV

#Requires OpenCV FIND_PACKAGE(OpenCV 3.0.0 REQUIRED) MESSAGE("OpenCV version : ${OpenCV_VERSION}")

include_directories(${OpenCV_INCLUDE_DIRS}) link_directories(${OpenCV_LIB_DIR}) ADD_EXECUTABLE(app main.cpp) TARGET_LINK_LIBRARIES(app ${OpenCV_LIBS}) " without the doublequotes at the start and the end. Save the file.

  1. Now open the terminal and go to the directory where these file are stored. And in the terminal type "cmake ." ,without the doublequotes.
  2. Now in the terminal type "make" and press enter.
  3. It will compile and generate an executable file name app
  4. Execute the app file using ./app
  5. Hope it helps.