opencv创建错误的pkg-config文件

时间:2014-12-11 16:06:53

标签: c++ opencv cmake pkg-config

如果我像这样直接安装opencv:

mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX="/some/path" ..
make install

opencv会创建一个错误的pkg-config文件,如下所示:

# Package Information for pkg-config

prefix=/some/path
exec_prefix=${prefix}
libdir=
includedir_old=${prefix}/include/opencv
includedir_new=${prefix}/include

Name: OpenCV
Description: Open Source Computer Vision Library
Version: 2.4.10
Libs:  ${exec_prefix}/lib/libopencv_calib3d.so ${exec_prefix}/lib/libopencv_contrib.so ${exec_prefix}/lib/libopencv_core.so ${exec_prefix}/lib/libopencv_features2d.so ${exec_prefix}/lib/libopencv_flann.so ${exec_prefix}/lib/libopencv_gpu.so ${exec_prefix}/lib/libopencv_highgui.so ${exec_prefix}/lib/libopencv_imgproc.so ${exec_prefix}/lib/libopencv_legacy.so ${exec_prefix}/lib/libopencv_ml.so ${exec_prefix}/lib/libopencv_nonfree.so ${exec_prefix}/lib/libopencv_objdetect.so ${exec_prefix}/lib/libopencv_ocl.so ${exec_prefix}/lib/libopencv_photo.so ${exec_prefix}/lib/libopencv_stitching.so ${exec_prefix}/lib/libopencv_superres.so ${exec_prefix}/lib/libopencv_ts.a ${exec_prefix}/lib/libopencv_video.so ${exec_prefix}/lib/libopencv_videostab.so -lrt -lpthread -lm -ldl
Cflags: -I${includedir_old} -I${includedir_new}

哪个产生输出,不能直接用于编译器,或者通过cmake:

$ pkg-config opencv --libs
/sct/homes3/opencv/opencv_2_4_10/lib/libopencv_calib3d.so /sct/homes3/opencv/opencv_2_4_10/lib/libopencv_contrib.so /sct/homes3/opencv/opencv_2_4_10/lib/libopencv_core.so /sct/homes3/opencv/opencv_2_4_10/lib/libopencv_features2d.so /sct/homes3/opencv/opencv_2_4_10/lib/libopencv_flann.so /sct/homes3/opencv/opencv_2_4_10/lib/libopencv_gpu.so /sct/homes3/opencv/opencv_2_4_10/lib/libopencv_highgui.so /sct/homes3/opencv/opencv_2_4_10/lib/libopencv_imgproc.so /sct/homes3/opencv/opencv_2_4_10/lib/libopencv_legacy.so /sct/homes3/opencv/opencv_2_4_10/lib/libopencv_ml.so /sct/homes3/opencv/opencv_2_4_10/lib/libopencv_nonfree.so /sct/homes3/opencv/opencv_2_4_10/lib/libopencv_objdetect.so /sct/homes3/opencv/opencv_2_4_10/lib/libopencv_ocl.so /sct/homes3/opencv/opencv_2_4_10/lib/libopencv_photo.so /sct/homes3/opencv/opencv_2_4_10/lib/libopencv_stitching.so /sct/homes3/opencv/opencv_2_4_10/lib/libopencv_superres.so /sct/homes3/opencv/opencv_2_4_10/lib/libopencv_ts.a /sct/homes3/opencv/opencv_2_4_10/lib/libopencv_video.so /sct/homes3/opencv/opencv_2_4_10/lib/libopencv_videostab.so -lrt -lpthread -lm -ldl

你可以看到opencv的库是由它们的完整路径给出的,并且没有给出编译器标志。

opencv.pc的正确版本应如下所示:

# Package Information for pkg-config

prefix=/some/path
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir_old=${prefix}/include/opencv
includedir_new=${prefix}/include

Name: OpenCV
Description: Open Source Computer Vision Library
Version: 2.4.10
Libs:  -L${libdir} -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 -lrt -lpthread -lm -ldl
Cflags: -I${includedir_old} -I${includedir_new}

那么为什么opencv / cmake会产生这样一个pkg-config文件呢? 或者我对make install做错了什么?

0 个答案:

没有答案