Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Hi i've tried following the instructions from this website http://robotica.unileon.es/mediawiki/index.php/Objects_recognition_and_position_calculation_(webcam)

At the part where they asked to add this :

find_package(OpenCV "VERSION" REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
...
target_link_libraries("PROGRAM_NAME" ${OpenCV_LIBS})

i added and tried to build the package but it resulted in the errors:

Parse error.  Expected a command name, got unquoted argument with text "...".
-- Configuring incomplete, errors occurred!
make: *** [cmake_check_build_system] Error 1
Invoking "make cmake_check_build_system" failed

Could any one please help me resolve this error?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
274 views
Welcome To Ask or Share your Answers For Others

1 Answer

This basically describes how you're able to add OpenCV to your own program, if you're actually using CMake.

The text in quotes has to be replaced with your actual values/project names, for example, if my target is called myopencvthing and I'd want to use OpenCV 2.0 or newer, then I'd setup something like this:

# First tell CMake the minimal version of CMake expected
cmake_minimum_required(VERSION 2.8)

# Define a project
project(myopencvproject)

# Tell CMake to look for OpenCV 2.0 (and tell it that it's required, not optional)
find_package(OpenCV 2.0 REQUIRED)

# Tell CMake to add the OpenCV include directory for the preprocessor
include_directories(${OpenCV_INCLUDE_DIRS})

# Add the source files to a variable
set(SOURCES main.cpp processing.cpp somethingelse.cpp)

# Define the actual executable target and the source files
add_executable(myopencvthing ${SOURCES})

# Finally, add the dependencies of our executable (i.e. OpenCV):
target_link_libraries(myopencvthing ${OpenCV_LIBS})

Now you'll just have to run CMake to create your actual makefiles or project files and then build everything, e.g.:

cd /my/build/dir
cmake /path/to/my/source
make

If CMake fails to find the specified dependencies, then you'll have to open the CMakeCache.txt file and edit those paths by hand (or use cmake-gui in case you prefer a more visual editor).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...