【问题标题】:Build errors while following the instructions given on a website按照网站上给出的说明构建错误
【发布时间】:2015-01-09 02:58:53
【问题描述】:

您好,我已尝试按照本网站 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

谁能帮我解决这个错误?

【问题讨论】:

  • 啊,很好。与您的挤入评论相比,这现在更容易解释。 :)
  • @Mario Hey 你能查看我的链接吗:stackoverflow.com/questions/27889141/…我有一个无法解决的错误
  • @Mario 嘿,这是我要问的最后一个问题,感谢您迄今为止的帮助。你真的帮了我很多,我从你身上学到了很多。如果可能,请帮助我解决最后一个问题:stackoverflow.com/questions/28020473/…

标签: opencv cmake


【解决方案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,以防您喜欢更直观的编辑器)。

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2021-07-07
      • 1970-01-01
      • 1970-01-01
      • 2020-03-25
      • 1970-01-01
      • 1970-01-01
      • 2021-06-02
      • 2013-01-06
      • 2017-04-28
      相关资源
      最近更新 更多