[Unix] 如果pkg-config找不到某库的路径

pkg-config的原理是:每个由pkg-config管理的库都会提供一个后缀为.pc的文件,pkg-config不过是把这个文件读出,分析并打印在屏幕上罢了。

比如opencv的pc文件(opencv.pc):

 
    
# Package Information for pkg-config

prefix
=/ usr / local
exec_prefix
=$ {prefix}
libdir
=$ {exec_prefix} / lib
includedir_old
=$ {prefix} / include / opencv
includedir_new
=$ {prefix} / include

Name: OpenCV
Description: Open Source Computer Vision Library
Version:
2.2 . 0
Libs: -L
$ {libdir} -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann
Cflags: -I
$ {includedir_old} -I $ {includedir_new}

如果pkg-config找不到某个库的路径,需要做的就是找到该库的pc文件,然后拷到pkg-config指定的路径下就行了。pc文件一般在编译时会生成,pkg-config指定的路径,在osx下如果是用macports安装的pkg-config,则会在/opt/local/lib/pkgconfig。

转载于:https://www.cnblogs.com/nicebear/archive/2011/05/14/2046198.html

你可能感兴趣的:([Unix] 如果pkg-config找不到某库的路径)