zoukankan      html  css  js  c++  java
  • Package opencv was not found in the pkg-config search path.

    安装好后opencv后执行下面这条语句的时候出错:

    pkg-config --cflags opencv


    Package opencv was not found in the pkg-config search path.
    Perhaps you should add the directory containing `opencv.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'opencv' found


    经过网上详细查询资料后,是缺失了opencv.pc这个配置信息文件,故解决方法就是添加这个文件然后将其导入到环境变量中,具体操作如下:

    首先创建opencv.pc文件,这里要注意它的路径信息:

    cd /usr/local/lib
    sudo mkdir pkgconfig
    cd pkgconfig
    sudo touch opencv.pc


    然后在opencv.pc中添加以下信息,注意这些信息需要与自己安装opencv时的库路径对应:
    prefix=/usr/local
    exec_prefix=${prefix}
    includedir=${prefix}/include
    libdir=${exec_prefix}/lib

    Name: opencv
    Description: The opencv library
    Version:4.0.1
    Cflags: -I${includedir}/opencv4
    Libs: -L${libdir} -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann  -lopencv_core


    保存退出,然后将文件导入到环境变量:
    export  PKG_CONFIG_PATH=/usr/local/lib/pkgconfig


    至此就配置好opencv.pc啦~
    再执行 pkg-config --cflags --libs opencv时输出结果如下:

    -I/usr/local/include/opencv4 -L/usr/local/lib
    -lopencv_stitching -lopencv_objdetect
    -lopencv_calib3d
     -lopencv_features2d -lopencv_highgui -lopencv_videoio
     -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml
     -lopencv_imgproc -lopencv_flann -lopencv_core

  • 相关阅读:
    codeforces 672B B. Different is Good(水题)
    codeforces 672A A. Summer Camp(水题)
    poj-1273 Drainage Ditches(最大流基础题)
    hdu-3592 World Exhibition(差分约束)
    poj-1201 Intervals(差分约束)
    解决Windows只能打英文输入法图标不见不显示问题
    Windows查看MD5码
    Windows中类似 linux netstat grep命令
    清空所有账户回收站
    PLSQL dev字符集乱码设置
  • 原文地址:https://www.cnblogs.com/tianpeng-blog/p/14744572.html
Copyright © 2011-2022 走看看