I’ve compiled a Python module using my own Qt4 library located in ~/opt/qt-4.6.0/,
but when I try to import that module, the dynamic libraries that get loaded are from my MacPorts Qt4 installation.
$ /opt/local/bin/python2.6
>>> import vtk
objc[58041]: Class QMacSoundDelegate is implemented in both /Users/luis/opt/qt-4.6.0/lib/QtGui.framework/Versions/4/QtGui and /opt/local/libexec/qt4-mac/lib/QtGui.framework/Versions/4/QtGui. Using implementation from /opt/local/libexec/qt4-mac/lib/QtGui.framework/Versions/4/QtGui.
objc[58045]: Class QCocoaColorPanelDelegate is implemented in both /Users/luis/opt/qt-4.6.0/lib/QtGui.framework/Versions/4/QtGui and /opt/local/libexec/qt4-mac/lib/QtGui.framework/Versions/4/QtGui. Using implementation from /opt/local/libexec/qt4-mac/lib/QtGui.framework/Versions/4/QtGui.
[... more output like above ...]
>>>
Is there a way of telling Python (also installed from MacPorts) to load the frameworks located in my ~/opt/qt-4.6.0/lib/ directory? I’m not sure what environment variables to change.
Try setting the
DYLD_LIBRARY_PATHto put your libraries in~/opt/qt/...before the MacPorts’ libraries before invoking python (take a look at~/.profilefor an example of how to do this if you don’t know; MacPorts does the exact same thing to put its libraries on theDYLD_LIBRARY_PATH).dyld, the OS X dynamic linker usesDYLD_LIBRARY_PATHto find libraries at load time (among other methods); Seeman dyldfor more info.