变态的pkg-config

关于pkg-config的说明:

 

为了解决引用各种第三方库时的cflags和ldflags的设置问题,pkg-config被引进到编译配置中来,以便为了用一种统一的方式来自动设置项目所依赖cflags和ldflags等参数, 

 

pkg-config是通过库提供的一个 .pc 文件获得库的各种必要信息的,包括版本信息、编译和连接需要的参数等。这些信息可以通过 pkg-config提供的参数单独提取出来直接供编译器和连接器使用。

 

官方的说明如下:

 

 

The pkgconfig package contains tools for passing the include path and/or library paths to build tools during the make file execution.

 

pkg-config is a function that returns meta information for the specified library.

 

The default setting for PKG_CONFIG_PATH is /usr/lib/pkgconfig because of the prefix we use to install pkgconfig.You may add to PKG_CONFIG_PATH by exporting additional paths on your system where pkgconfig files are installed.Note that PKG_CONFIG_PATH is only needed when compiling packages, not during run-time.

 

 

-----------------------------------------------

pkg-config的使用本来非常简单,但是我今天晚上遇到了一个极其诡异的事情, pkg-config 不认识配置文件中的${prefix}了

 

如下,假设我有一个libavcodec.pc内容如下:

 

 

prefix=/home/ffmpeg_build

exec_prefix=${prefix}

libdir=${prefix}/lib

includedir=${prefix}/include

 

Name: libavcodec

Description: FFmpeg codec library

Version: 52.47.0

Requires: 

Requires.private: libavutil = 50.7.0

Conflicts:

Libs: -L${libdir} -lavcodec 

Libs.private: -lz -lbz2 -lm -lvfw32 -LE:/msys/local/lib -ldirac_encoder -ldirac_decoder -lm -lstdc++ -LE:/msys/local/lib -ldirac_encoder -ldirac_decoder -lm -lstdc++ -lfaac -lfaad -lgsm -lmp3lame -lm -lopencore-amrnb -lm -lopencore-amrwb -lm -lopenjpeg -LE:/msys/local/lib -lschroedinger-1.0 -loil-0.3 -lm -lspeex -ltheoraenc -ltheoradec -logg -lvorbisenc -lvorbis -logg -lx264 -lm -lxvidcore -lws2_32 -lvfw32 -lpthreadGC2 -lstdc++

Cflags: -I${includedir}

-----------------------------------
理论上我如果用执行如下命令:
pkg-config --libs libavcodec
则应该输出:
-L/home/ffmpeg_build/lib -lavcodec
但是我这边却出现了如下诡异的输出:
-L/usr/local/lib -lavcodec
也就是说${prefix}的设置被忽略了, 在pkg-config看来你无论设置任何值,${prefix}永远都是 /usr/local
这就使得所有prefix不是/usr/local的第三方软件在用pkg-config来侦测的时候都失败
我暂时将我的prefix也设置成了/usr/local,虽然这最终解决我的问题,但我还是想知道问题的根源是什么?
继续查资料中.......

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值