我不能在保存我的CMakeLists和/或建设项目得到我的克利翁打造,因为一个奇怪的错误的项目: Error:Found package configuration file: /usr/share/opencv/OpenCVConfig.cmake but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be NOT FOUND.
OpenCV的克利翁(CMake的)连结的问题 - cmake的报告奇怪的错误
来源文件:
#include <stdio.h>
#include <opencv2/opencv.hpp>
using namespace cv;
int main(int argc, char** argv)
{
Mat image;
image = imread("lena.jpg", 1);
if (!image.data)
{
printf("No image data \n");
return -1;
}
namedWindow("Display Image", WINDOW_AUTOSIZE);
imshow("Display Image", image);
waitKey(0);
return 0;
}
我的CMakeLists.txt: cmake_minimum_required(VERSION 3.3) project(Test) find_package(OpenCV REQUIRED) add_executable(Test main.cpp) target_link_libraries(Test ${OpenCV_LIBS})
$ pkg配置--cflags OpenCV的 -I/usr/include/opencv
$ pkg配置--libs OpenCV的 -L/lib64 -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_objdetect -lopencv_ocl -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videostab -ltbb -lGL -lGLU -lrt -lpthread -lm -ldl
的事实是,当我手动cmake . & make
(所有相同CMakeLists文件)从控制台我的项目,它工作得很好用没有错误。
OpenCV版本:2.4.11-1(arch linux) CLion:最新版本。
与git版本相比OpenCVConfig.cmake的区别:https:// www.diffchecker。 COM/vtmmiu1w
手动生成输出:
[dobegor[email protected] Test]$ cmake .
-- The C compiler identification is GNU 5.2.0
-- The CXX compiler identification is GNU 5.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/dobegor/ClionProjects/Test
[[email protected] Test]$ make
Scanning dependencies of target Test
[ 50%] Building CXX object CMakeFiles/Test.dir/main.cpp.o
[100%] Linking CXX executable Test
[100%] Built target Test
我坚持,我想近一切可能。这里有类似的问题,但它没有解决。 – 12sd
当手动构建项目时,可以执行* in-source build *(从源目录运行cmake),不是吗?它可能与由CLion执行的* out-source * build相冲突。 – Tsyvarev
@Tsyvarev是的,但我无法弄清楚在内源和外源之间搜索CMake包有什么区别。 – 12sd