All Articles

Compile against libraries installed with MacPorts

MacPorts installs packages in a non unix-standard location. This can cause problems when trying to compile other software against these packages because they aren’t found by the configure script.

I experienced that problem when trying to compile SDL_image, which depends on libraries such as libpng. I had to configure with the following flags :

./configure CPPFLAGS="-I/opt/local/include" LDFLAGS="-L/opt/local/lib"

which indicates in which folders the libraries installed with MacPorts were installed.

Published Jan 22, 2008

I am a computer scientist specializing in building machine learning powered products. I’m currently a machine learning developer at Local Logic.

4 thoughts on "Compile against libraries installed with MacPorts"

Thuan

Commented 2011-03-28 23:19:59

Thank you for this tip! It's just what I needed.

Brian Morris

Commented 2011-06-13 23:23:40

Thanks for your help here. I am trying to compile a upstreamed patched package from git source against macports and having had trouble building against Macports for dependencies -- your suggestion eliminates some of it.

However I am still not getting access to the python pyGTK library. If I were good with python maybe this would be clear or maybe not. it is for the header files to build against. Any clear ideas what I should add ?

I am building gimp2.7 (w/ proposed gimp-painter patches) on 10.6

Brian Morris

Commented 2011-06-16 21:50:01

Update - Although setting the python variables shown below, but in the shell, i can run the pygtk demos just fine, the following does not work:

./configure "CPPFLAGS=-I/opt/local/include -I/opt/local/Library/Frameworks/Python.framework/Versions/2.6/share/pygtk/2.0/defs" "LDFLAGS=-L/opt/local/lib" "PYTHONHOME=/opt/local/Library/Frameworks/Python.framework/Versions/2.6" "PYTHONPATH=/opt/local/lib/python2.6"

but produces

checking for a Python interpreter with version >= 2.5.0... python

checking for python... /opt/local/bin/python

checking for python version... 2.6

checking for python platform... darwin

checking for python script directory... ${prefix}/lib/python2.6/site-packages

checking for python extension module directory... ${exec_prefix}/lib/python2.6/site-packages

checking for headers required to compile python extensions... found

checking for PYGTK... no

configure: error:

*** Could not find PyGTK 2.10.4 or newer.

*** Please install it, or skip building the python scripting extension by

*** passing --disable-python to configure (but then you will not be able

*** to use scripts for GIMP that are written in Python).

Arjun G. Menon

Commented 2015-05-29 01:04:08

Thanks for this tip -- this is exactly what I needed!