如何告诉 MacPorts 我已经安装了某个库?
例如,我从头开始构建了 libcurl
,以使用 nghttp2
、openssl
和 zlib
获取 http2 协议(protocol)。我将它们安装到 /opt/local
——与我系统上所有 MacPort 库相同的位置。但是,Macports 无法识别它们已安装。
我如何告诉 MacPorts 这些及其版本已经安装?为什么?因为我正在尝试这样做:
port install py35-pip
但它列出了 libz
和 openssl
未安装。
最佳答案
出于多种原因,MacPorts 不支持此功能:
- 您不应手动修改
/opt/local
中通常由 MacPorts 管理的文件。 MacPorts 会保留有关已安装文件的某些元数据(例如所需的依赖项),当您在/opt/local
中手动安装文件时,这些元数据将不再起作用。 - MacPorts 不知道您使用哪种配置来构建您手动安装在
/opt/local
中的二进制文件。它可能是一个不再适用于某种依赖项的版本,它可能是针对 C++ 代码的不同 C++ 标准库构建的,或者它可能由于许多其他原因而不兼容。因为 MacPorts 希望减少对像这样修改了某些端口的用户的请求的支持负担,所以 MacPorts 不支持这样做。
但是,MacPorts 已经支持安装带有 nghttp2 支持的curl。查看端口变体curl
的输出:
curl has the variants:
ares: Support resolving names asynchronously
darwinssl: Allow secure connections using GNU TLS
* conflicts with gnutls ssl wolfssl
gnutls: Allow secure connections using GNU TLS
* conflicts with darwinssl ssl wolfssl
gss: Support the Generic Security Service API
http2: Support HTTP/2 with nghttp2
idn: Enable support for internationalized domain names (IDN)
metalink: Support Metalink XML download description files
openldap: Support performing Lightweight Directory Access Protocol queries with OpenLDAP
sftp_scp: Support SFTP/SCP connections via libssh2
spnego: Enable SPNEGO authentication support
[+]ssl: Allow secure connections using OpenSSL
* conflicts with darwinssl gnutls wolfssl
universal: Build for multiple architectures
wolfssl: Allow secure connections using wolfSSL, formerly CyaSSL
* conflicts with darwinssl gnutls ssl
因此,在这种情况下,您可以使用 sudo port install curl +http2
(如果您尚未安装)来安装 curl +http2
,或者使用 sudo port Upgrade --enforce-variants curl +http2(如果您已经安装了它)来实现同样的效果。
另请参阅https://trac.macports.org/wiki/FAQ#usrlocal一般适用于 /usr/local
和 MacPorts。
关于Macports 注册从源代码构建的现有库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42184591/