Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Opencv 按照网站上给出的说明生成错误_Opencv_Cmake - Fatal编程技术网

Opencv 按照网站上给出的说明生成错误

Opencv 按照网站上给出的说明生成错误,opencv,cmake,Opencv,Cmake,嗨,我试着按照这个网站上的说明去做 在他们要求添加以下内容的部分: 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 a

嗨,我试着按照这个网站上的说明去做

在他们要求添加以下内容的部分:

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

有谁能帮我解决这个错误吗?

我想你应该用版本号和程序名替换“版本”和“程序名”。 这是 版本为2.4 和
程序名取决于您对可执行文件的命名。

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

引号中的文本必须替换为您的实际值/项目名称,例如,如果我的目标名为
myopenvthing
,并且我希望使用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来创建实际的Make文件或项目文件,然后构建所有内容,例如:

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

如果CMake无法找到指定的依赖项,那么您必须打开
CMakeCache.txt
文件并手动编辑这些路径(或者使用
CMake gui
,以防您更喜欢可视化编辑器)。

。现在,与您的压缩评论相比,这更容易理解。:)@Mario嘿,你能看看我的链接吗:我有一个错误,我不能solve@Mario嘿,这是我要问的最后一个问题,谢谢你迄今为止的帮助。你真的帮了我很多,我也从你那里学到了很多。如果可能,请帮我回答最后一个问题: