gpt4 book ai didi

centos - 使用 automake 在 CentOS 上将 pkg-config 文件安装到正确的路径

转载 作者:太空宇宙 更新时间:2023-11-03 17:13:00 31 4
gpt4 key购买 nike

我维护了几个使用 automake 构建的项目(我们称它们为 lib1 和 lib2)。 lib2 依赖于 lib1 作为库,我在 CentOS 上的 pkg-config 默认值有一些问题。理想情况下,我希望用户不必设置任何环境变量即可正确安装所有内容。

现在,它只是假设 ${PREFIX}/lib/pkgconfig作为我的 .pc 文件的目的地,但在 CentOS 7 上,默认为 ${PREFIX}/usr/local但是pkgconfig默认情况下只查找 /usr/share/pkgconfig/usr/lib64/pkgconfig .因此,lib2找不到 lib1pkg-config并且配置脚本爆炸了。

所以,问题是,我的 make install 怎么办?在 lib1正确检测目录以安装 pkg-config文件?

最佳答案

来自 man pkg-config

PKG_INSTALLDIR(DIRECTORY)

Substitutes the variable pkgconfigdir as the location where a module should install pkg-config .pc files. By default the directory is $libdir/pkgconfig, but the default can be changed by passing DIRECTORY. The user can override through the --with-pkgconfigdir parameter.

这允许您向用户公开 pkg-config 文件的安装目录(并且 - 如果您的发行版修补 pkg-config 以使用非标准搜索路径,它有望为您的系统选择正确的默认值) .

例子:

配置文件:

[...]
PKG_INSTALLDIR
[...]

生成文件.am:

[...]
pkgconfig_DATA = lib1.pc
[...]

用法

$ ./configure --prefix=/usr --with-pkgconfigdir=/usr/lib64/pkgconfig

注意事项

请不要对 pkg-config 将在何处查找文件做出特定于发行版的假设。始终使用默认值(它们是默认值是有充分理由的),并提供一种方法来覆盖非标准系统的这些默认值。

那里有很多发行版,仅仅因为在我的社区中一个流行,这并不意味着其他社区也是如此(或不会改变)。

如果您的发行版不遵循标准也没关系,但它应该是一致的;如果它不一致(例如 pkg-config/foo/baz 中寻找文件,但是 PKG_INSTALLDIR 扩展 pkgconfigdir/usr/lib/pkg-config),那么你应该在你的发行版中报告一个错误。

另外我觉得很奇怪,您的pkg-config 不会在/usr/local 中搜索文件。例如。在我的 Debian/sid 系统上,它首先搜索 /usr/local,然后搜索 /usr:

$ which pkg-config
/usr/bin/pkg-config

$ strace -e trace=open pkg-config --cflags foo 2>&1 | grep /usr
open("/usr/local/lib/x86_64-linux-gnu/pkgconfig", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/pkgconfig", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/share/pkgconfig", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/pkgconfig", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("/usr/lib/pkgconfig", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("/usr/share/pkgconfig", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
$

关于centos - 使用 automake 在 CentOS 上将 pkg-config 文件安装到正确的路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28997618/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com