按照网站上给出的说明构建错误



嗨,我尝试按照本网站的说明进行操作 http://robotica.unileon.es/mediawiki/index.php/Objects_recognition_and_position_calculation_(网络摄像头)

在他们要求添加的部分:

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

任何人都可以帮我解决此错误吗?

这基本上描述了如果你实际使用CMake,如何将OpenCV添加到你自己的程序中。

引号中的文本必须替换为您的实际值/项目名称,例如,如果我的目标称为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)。

我认为您应该将"VERSION"和"PROGRAM_NAME"替换为版本号和程序名称。这是2.4 版本和程序名称由您命名的可执行文件的任何名称。

最新更新