opencv项目中的CMakeLists.txt出错

时间:2014-11-05 19:54:39

标签: c++ opencv cmake

我正在用C ++开始一个opencv项目,我认为这将是学习一些cmake的好时机。这是我的项目雇佣关系:

project/
|__include/
   |__sample1.h
   |__sample2.h
|__build/
|__doc/
|__src/
   |__sample1.cpp
   |__sample2.cpp
|__test/
   |__main.cpp
|__CMakeLists.txt

CMakeLists.txt是:

CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )

SET( PROJ_NAME      "Project" )
SET( PROJ_PATH      ${CMAKE_SOURCE_DIR} )
SET( PROJ_OUT_PATH  ${CMAKE_BINARY_DIR} )
SET( PROJ_LIBRARIES ${OpenCV_LIBS} )
SET( PROJ_INCLUDES  "include" )

FILE( GLOB_RECURSE PROJ_SOURCES src/*cpp test/*cpp )
FILE( GLOB_RECURSE PROJ_HEADERS include/${PROJ_NAME}/*.h )

PROJECT( ${PROJ_NAME} )
FIND_PACKAGE( OpenCV REQUIRED )
INCLUDE_DIRECTORIES( ${PROJ_INCLUDES} )
ADD_EXECUTABLE( ${PROJ_NAME} ${PROJ_SOURCES} )
TARGET_LINK_LIBRARIES( ${PROJ_NAME} ${PROJ_LIBRARIES} )

生成makefile,但是当我执行“make”时,我对opencv函数有一些“未定义的引用”。

任何帮助将不胜感激,当然如果您想了解更多信息,请询问:)

由于

1 个答案:

答案 0 :(得分:0)

SET( PROJ_LIBRARIES ${OpenCV_LIBS} )

OpenCV_LIBS将在您使用find_package()搜索包之后设置。

您还需要将标头添加到add_executable()。