bgo*_*odr 4 rhel openssl pkg-config
我在 RHEL 6.8 Linux 机器上运行。我正在寻求从源 tarballs/git-repos/whatefer 构建各种包,而无需更改系统配置(在 root 或 sudo 下)。
我在 RHEL 6.8 机器上运行:
bash-4.1$ cat /etc/issue
Red Hat Enterprise Linux Workstation release 6.8 (Santiago)
Kernel \r on an \m
Run Code Online (Sandbox Code Playgroud)
openssl-devel
已安装:
bash-4.1$ rpm -q -a | grep openssl
openssl-1.0.1e-48.el6.i686
openssl098e-0.9.8e-20.el6_7.1.x86_64
openssl098e-0.9.8e-20.el6_7.1.i686
openssl-devel-1.0.1e-48.el6.i686
openssl-1.0.1e-48.el6.x86_64
openssl-devel-1.0.1e-48.el6.x86_64
Run Code Online (Sandbox Code Playgroud)
所以我希望这个命令返回一些输出,这样当我从使用 pkg-config 的源构建包时,他们会找到他们需要的 CFLAGS 的值:
bash-4.1$ pkg-config --cflags openssl
Run Code Online (Sandbox Code Playgroud)
但它只返回一个换行符。为什么?
进一步调试:
显示正在使用的文件:
bash-4.1$ pkg-config --debug --list-all 2>&1 | grep 'Will find package.*openssl'
Will find package 'openssl' in file '/usr/lib64/pkgconfig/openssl.pc'
Run Code Online (Sandbox Code Playgroud)
显示它应该读取的文件:
bash-4.1$ cat /usr/lib64/pkgconfig/openssl.pc
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib64
includedir=${prefix}/include
Name: OpenSSL
Description: Secure Sockets Layer and cryptography libraries and tools
Version: 1.0.1e
Requires:
Libs: -L${libdir} -lssl -lcrypto
Libs.private: -Wl,-z,relro -ldl -lz -L/usr/lib -lgssapi_krb5 -lkrb5 -lcom_err -lk5crypto -lresolv
Cflags: -I${includedir} -I/usr/include
Run Code Online (Sandbox Code Playgroud)
扩大grep:
bash-4.1$ pkg-config --debug --list-all 2>&1 | grep 'openssl'
File 'openssl.pc' appears to be a .pc file
Will find package 'openssl' in file '/usr/lib64/pkgconfig/openssl.pc'
Looking for package 'openssl'
Looking for package 'openssl-uninstalled'
Reading 'openssl' from file '/usr/lib64/pkgconfig/openssl.pc'
Parsing package file '/usr/lib64/pkgconfig/openssl.pc'
Unknown keyword 'Libs.private' in '/usr/lib64/pkgconfig/openssl.pc'
Removing -I/usr/include from cflags for openssl
Removing -I/usr/include from cflags for openssl
Removing -L /usr/lib64 from libs for openssl
Adding 'openssl' to list of known packages, returning as package 'openssl'
openssl OpenSSL - Secure Sockets Layer and cryptography libraries and tools
bash-4.1$
Run Code Online (Sandbox Code Playgroud)
嗯,那Removing -I/usr/include from cflags for openssl
在那里做什么?
此外,Cflags
还定义了变量。这是一个错误吗?应该cflags
改为吗?
另外,我已经下载并构建了我自己的pkg-config
0.29.2 版,它提供了相同的行为。所以我怀疑openssl.pc
文件中有错误,但我不确定。
即便如此,什么是修复比出口的硬编码值等CFLAGS
,并LDFLAGS
调用各种包之前,为了./configure
脚本?
看起来像是pkg-config
去重复标志并且还跳过了“默认”路径,比如 /usr/include。
看,
$ printf "Name: whatever\nVersion: 1\nDescription: bla\nCflags: -I/usr/include" > /tmp/x.pc
$ pkg-config --cflags /tmp/x.pc
$ printf "Name: whatever\nVersion: 1\nDescription: bla\nCflags: -I/usr/includeX" > /tmp/y.pc
$ pkg-config --cflags /tmp/y.pc
-I/usr/includeX
Run Code Online (Sandbox Code Playgroud)
这些默认目录是在 pkg-config 的构建时设置的,请参阅源代码中的 README.md:
./configure \
--prefix=/opt/pkgconf \
--with-system-libdir=/lib:/usr/lib \
--with-system-includedir=/usr/include
Run Code Online (Sandbox Code Playgroud)
您可以在运行时通过环境变量禁用该行为:
$ PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 pkg-config --cflags /tmp/x.pc
-I/usr/include
Run Code Online (Sandbox Code Playgroud)
或覆盖内置默认值:
$ PKG_CONFIG_SYSTEM_INCLUDE_PATH="/whatever" pkg-config --cflags /tmp/x.pc
-I/usr/include
Run Code Online (Sandbox Code Playgroud)
最近的 pkg-config 也有命令行选项--keep-system-cflags
和--keep-system-libs
归档时间: |
|
查看次数: |
3659 次 |
最近记录: |