簡體   English   中英

CMake添加opencv

[英]CMake adding opencv

我試圖在cmake中包含opencv2.4.9:

cmake_minimum_required(VERSION 2.8.3)
project(HydroCamel)
SET(CMAKE_CXX_FLAGS "-lpthread")
find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
)
catkin_package()
set(SRC_FOLDER src/src)
set(ALOGS_FOLDER src/Algos)
set(ALOGS_UTILS_FOLDER src/Algos/Utils)
set(SRC_INCLUDE_FOLDER src/include)
set(DIRS ${SRC_FOLDER} ${ALOGS_FOLDER} ${ALOGS_UTILS_FOLDER} ${SRC_INCLUDE_FOLDER})
include_directories(${DIRS})

file(GLOB_RECURSE SRC_FILES "*.h" "*.cpp")
include_directories(include ${catkin_INCLUDE_DIRS})

set(Boost_USE_STATIC_LIBS OFF) 
set(Boost_USE_MULTITHREADED ON)  
set(Boost_USE_STATIC_RUNTIME OFF) 
find_package(Boost 1.55.0 COMPONENTS filesystem system thread)
#FIND_PACKAGE(OpenCV REQUIRED core imgproc highgui)
include_directories(${OpenCV_INCLUDE_DIRS})
if(Boost_FOUND)
    include_directories(${Boost_INCLUDE_DIRS}) 
    add_executable(SourceFiles ${SRC_FILES})
    TARGET_LINK_LIBRARIES(SourceFiles ${Boost_LIBRARIES})
    TARGET_LINK_LIBRARIES(SourceFiles ${OpenCV_LIBS})
endif()

我收到此錯誤:

HydroCamel / CMakeLists.txt:28(find_package)的CMake錯誤:找到程序包配置文件:

 /home/jdorfsman/opencv-2.4.9/build/OpenCVConfig.cmake 

但是將OpenCV_FOUND設置為FALSE,因此認為軟件包“ OpenCV”未找到。

-配置不完整,發生錯誤! 另請參閱“ /home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeOutput.log”。 另請參閱“ /home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeError.log”。

這是CMakeError.log文件:

Determining if the pthread_create exist failed with the following output:
Change Dir: /home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeTmp

Run Build Command:/usr/bin/make "cmTryCompileExec1061744568/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec1061744568.dir/build.make CMakeFiles/cmTryCompileExec1061744568.dir/build
make[1]: Entering directory `/home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec1061744568.dir/CheckSymbolExists.c.o
/usr/bin/cc    -o CMakeFiles/cmTryCompileExec1061744568.dir/CheckSymbolExists.c.o   -c /home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTryCompileExec1061744568
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec1061744568.dir/link.txt --verbose=1
/usr/bin/cc       CMakeFiles/cmTryCompileExec1061744568.dir/CheckSymbolExists.c.o  -o cmTryCompileExec1061744568 -rdynamic 
CMakeFiles/cmTryCompileExec1061744568.dir/CheckSymbolExists.c.o: In function `main':
CheckSymbolExists.c:(.text+0x16): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
make[1]: *** [cmTryCompileExec1061744568] Error 1
make[1]: Leaving directory `/home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeTmp'
make: *** [cmTryCompileExec1061744568/fast] Error 2

File /home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <pthread.h>

int main(int argc, char** argv)
{
  (void)argv;
#ifndef pthread_create
  return ((int*)(&pthread_create))[argc];
#else
  (void)argc;
  return 0;
#endif
}

Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeTmp

Run Build Command:/usr/bin/make "cmTryCompileExec3426763052/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec3426763052.dir/build.make CMakeFiles/cmTryCompileExec3426763052.dir/build
make[1]: Entering directory `/home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec3426763052.dir/CheckFunctionExists.c.o
/usr/bin/cc   -DCHECK_FUNCTION_EXISTS=pthread_create   -o CMakeFiles/cmTryCompileExec3426763052.dir/CheckFunctionExists.c.o   -c /usr/share/cmake-2.8/Modules/CheckFunctionExists.c
Linking C executable cmTryCompileExec3426763052
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec3426763052.dir/link.txt --verbose=1
/usr/bin/cc   -DCHECK_FUNCTION_EXISTS=pthread_create    CMakeFiles/cmTryCompileExec3426763052.dir/CheckFunctionExists.c.o  -o cmTryCompileExec3426763052 -rdynamic -lpthreads 
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
make[1]: *** [cmTryCompileExec3426763052] Error 1
make[1]: Leaving directory `/home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeTmp'
make: *** [cmTryCompileExec3426763052/fast] Error 2

看起來您沒有指定pthread標志。

CMakeFiles/cmTryCompileExec1061744568.dir/CheckSymbolExists.c.o: In function `main':
CheckSymbolExists.c:(.text+0x16): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
make[1]: *** [cmTryCompileExec1061744568] Error 1
make[1]: Leaving directory `/home/jdorfsman/catkin_ws/build/CMakeFiles/CMakeTmp'
make: *** [cmTryCompileExec1061744568/fast] Error 2

嘗試添加:

SET(CMAKE_CXX_FLAGS "-lpthread")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM