Search code examples
macports

Macports register existing library built from source


How can I tell MacPorts that I already have a certain library installed?

For example, I built libcurl from scratch to get http2 protocol with nghttp2, openssl and zlib. I installed them to /opt/local -- same location as all MacPort libs on my system. However, Macports doesn't recognize that they are installed already.

How can I tell MacPorts that these are already installed as well as their versions? Why? Because I'm trying to do:

port install py35-pip but it lists that libz and openssl are not installed.


Solution

  • MacPorts does not support this, for multiple reasons:

    1. You should not manually modify files in /opt/local that would usually be managed by MacPorts. MacPorts keeps certain metadata (like the required dependencies) about installed files, which no longer works when you manually install files in /opt/local.
    2. MacPorts does not know which configuration you used to build the binary that you manually installed in /opt/local. It could be a version that no longer works with a certain dependency, it could be built against a different C++ standard library in case of C++ code, or it could be incompatible for a number of other reasons. Because MacPorts wants to reduce the support burden for requests from people that have modified some of their ports like that, it is not a support feature of MacPorts to do that.

    However, MacPorts already supports installing curl with nghttp2 support. See the output of port variants 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
    

    So in this case, you can just install curl +http2, either using sudo port install curl +http2 (if you didn't have it installed already) or using sudo port upgrade --enforce-variants curl +http2 (if you had it installed already) to achieve the same thing.

    See also https://trac.macports.org/wiki/FAQ#usrlocal for /usr/local and MacPorts in general.