我试图在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

#1楼 票数:0

看起来您没有指定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")

  ask by Javi translate from so

未解决问题?本站智能推荐:

1回复

尝试添加opencv库时CMake错误

我正在尝试使用深度传感器,并尝试获取灰度图像并使用OpenCV显示它。 我可以从深度传感器访问数据而没有任何问题。 但是,当我尝试在CMakeLists.txt中包含OpenCV部分时,出现以下错误: 我的CMakeLists.txt如下所示: 我是CMake的新手。 因此,我们将
1回复

CMake的openCV

我有以下问题,尽管我的项目使用CMake正确构建,但此后我出错,无法找到“ opencv2 / core / core.hpp”。 我正在发布我的CMakelists.txt配置,非常感谢您的帮助。 我还要补充一点,“查找包(需要OPENCV)”无法正常工作。
1回复

CMake不编译OpenCV

AFAIK,CMake是用于自动构建的工具,因此我对CMake的期望是“制作”整个内容,即,当我点击“ generate”时,它将创建所有文件并进行编译,因此我将拥有所有文件我需要。 但是,相反,当我在OpenCV上运行CMake时,它制作了VS2010解决方案和许多项目,然后我必须在VS2
1回复

CMake:如何仅包含部分OpenCV?

当我使用带有FIND_PACKAGE( OpenCV REQUIRED ) CMake FIND_PACKAGE( OpenCV REQUIRED ) , FIND_PACKAGE( OpenCV REQUIRED )所有组件都被包含在内并且所有lib都被链接,并且所有路径都显示在VS中的inc
2回复

CMake中的OpenCV和Gtest冲突

我正在尝试对我的应用程序进行一些Google测试,我遇到了OpenCV和GTest之间的一些冲突: GTest用于opencv_ts库。 有谁知道如何解决这些多重定义? 我想如果我只添加我在OpenCV使用的库,它将被解析,但我不知道如何做到这一点。 我努力了: 等,但我得到的错
1回复

CMake找不到OpenCV库

与此问题类似,我在OS X 10.10.3上使用OpenCV和CMake时遇到了麻烦。 经过一番麻烦,我终于设法在我的系统上构建OpenCV 3.0 beta; 标题现在位于/usr/local/include ,而libs - 正如它们应该 - 位于/usr/local/lib 。 我
1回复

如何更正CMAKE错误:找不到包“opencv”

好的,我知道之前已经讨论过opencv链接,但是我看不到错误并且我不明白纠正措施。 我正在尝试链接需要 opencv 的 DBoW2 库。 我收到未定义的参考错误。 这是 CMakeLists.txt 文件 我使用的是gui界面,参数OpenCV_DIR自动设置为C:/OpenCV/minwg_64
6回复

用Cmake和MinGW编译OpenCV2.4.13

我在尝试使用Cmake和mingw编译opencv时遇到了这个问题。 对于Cmake:sourcecode位于“C:\\ CPP Libraries \\ OpenCV-2.4.13 \\ opencv \\ sources”中,其中二进制文件是要构建的goint:“C:/ CPP Libr