您好我已尝试按照本网站http://robotica.unileon.es/mediawiki/index.php/Objects_recognition_and_position_calculation_(webcam)
的说明操作在他们要求添加的部分:
find_package(OpenCV "VERSION" REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
...
target_link_libraries("PROGRAM_NAME" ${OpenCV_LIBS})
我添加并尝试构建包但导致错误:
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
有人可以帮我解决这个错误吗?
答案 0 :(得分:1)
这基本上描述了如何将OpenCV添加到您自己的程序中,如果您实际使用的是CMake。
引号中的文字必须替换为您的实际值/项目名称,例如,如果我的目标被称为myopencvthing
并且我想要使用OpenCV 2.0或更新版本,那么我会设置一些东西像这样:
# 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})
现在你只需要运行CMake来创建你的实际makefile或项目文件然后构建所有内容,例如:
cd /my/build/dir
cmake /path/to/my/source
make
如果CMake无法找到指定的依赖项,那么您必须打开CMakeCache.txt
文件并手动编辑这些路径(或者如果您更喜欢可视化编辑器,请使用cmake-gui
)。
答案 1 :(得分:0)
我认为你应该用版本号和程序名替换“VERSION”和“PROGRAM_NAME”。 这是 2.4版本 和 任何你命名为可执行文件的程序名称。