可移植地将 GLib 头文件包含在 autoconf/automake 中
我需要包含使用基于 autoconf 的系统构建的项目的 GLib 标头可移植性。
如何以可移植的方式安全地导入 GLib 标头?我知道 pkg-config,但这并不完全可移植(因为某些系统不没有它,我宁愿只依赖 autoconf 进行配置)。
I need to include the GLib headers for a project that is built with an autoconf-based system for portability.
How can I safely import the GLib headers in a portable manner? I know about pkg-config, but that is not entirely portable (since some systems don't have it and I would prefer to only rely on autoconf for configuration).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通过使用
PKG_CHECK_MODULES
宏,Autoconf -生成的configure
脚本可以自动检索pkg-config数据。例如,将此行添加到您的configure.ac
文件中:将导致生成的
configure
脚本确保已安装的 glib-2.0 版本大于或等于版本 2.24.1 以及将pkg-config --cflags glib-2.0
和的输出附加到变量
DEPS_CFLAGS
和DEPS_LIBS
pkg-config --libs glib-2.0 分别。然后,您可以在_CFLAGS
和_LDADD
初选中使用$(DEPS_CFLAGS)
和$(DEPS_LIBS)
变量:By using the
PKG_CHECK_MODULES
macro, Autoconf-generatedconfigure
scripts can retrieve pkg-config data automatically. As an example, adding this line to yourconfigure.ac
file:will cause the resulting
configure
script to ensure that the installed version of glib-2.0 is greater than or equal to version 2.24.1 as well as append to variablesDEPS_CFLAGS
andDEPS_LIBS
the output ofpkg-config --cflags glib-2.0
andpkg-config --libs glib-2.0
, respectively. You then use the$(DEPS_CFLAGS)
and$(DEPS_LIBS)
variables in the_CFLAGS
and_LDADD
primaries:GLib 2.22 INSTALL 文件指出安装此库需要 pkg-config。我不是 GLib(双关语!);此要求的声明是
INSTALL
文件顶部的第一件事。从周围的文本来看,尚不清楚编译 GLib 本身是否需要 pkg-config ,但是很明显,GLib 2.22 作者并不打算让任何用户在没有 pkg-config 的情况下针对 GLib 进行编译。特别是,GLib 的
make install
将正确安装.pc
文件。为了平台可移植性,请指示用户适当设置
$PKG_CONFIG_PATH
。The GLib 2.22
INSTALL
file states thatpkg-config
is a requirement for installing this library. I am not being GLib (pun intended!); statement of this requirement is one of the first things on the top of theINSTALL
file.From the text surrounding it is unclear whether
pkg-config
is needed to compile GLib itself, however it is clear that GLib 2.22 authors do not intend for any users to compile against GLib without having pkg-config. In particular, GLib'smake install
will install.pc
files appropriately.For platform portability, instruct the user to set
$PKG_CONFIG_PATH
appropriately.