How to not install MacPorts dependency if installed elsewhere?

Solution 1:

In general, MacPorts uses only a small collection of “system” libraries and tools; it really has no facility for using separately built libraries, tools, environments, etc.

See the entries titled “Why is MacPorts using its own libraries?” and “Will MacPorts link to system libraries rather than its own?” in the MacPorts FAQ.


You might be able to adjust individual Portfiles to use your already-built stuff, but you will really be working “against the grain” of the MacPorts system; you will likely run into many difficulties when undertaking such an approach.

It might prove easier to just manually build the software that you are ultimately interested in; that way you have better control over which libraries it uses. If there are a lot of (non-Qt, non-Python) dependencies, and if you do not mind building them through MacPorts, then you could still use MacPorts to provide other dependencies:

 # make sure the list of other dependencies looks reasonable
port echo depof:someport and not python27 and not qt4-mac

# install the other dependencies
sudo port install depof:someport and not python27 and not qt4-mac

# configure; the way to specify the library locations will vary, but might be like this:
CFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib \
  ./configure --with-qt=/my/qt5/installation --with-python3=/my/python3/installation