Possibly incorrect dependencies specified in qt4-mac pkg-config files

Michael Dickens michaelld at macports.org
Wed Oct 12 17:36:51 PDT 2011


Hi Kieran - Well, that's a tricky one.  Let me elaborate; please bear with me.

See also < http://developer.apple.com/library/mac/#technotes/tn2124/_index.html#//apple_ref/doc/uid/DTS10003391-CH1-SECDYLD >, < http://developer.apple.com/library/mac/#technotes/tn2124/_index.html#//apple_ref/doc/uid/DTS10003391-CH1-SECDEBUGLIB >, and "man dyld" and search for SUFFIX.  This last item says:

DYLD_IMAGE_SUFFIX: This is set to a string of a suffix to try to be used for all shared libraries used by the program.  For libraries ending in ".dylib" the suffix is applied just before the ".dylib".  For all other libraries the suffix is appended to the library name.  This is useful for using conventional "_profile" and "_debug" libraries and frameworks.

So, at least in theory one could just do:

DYLD_IMAGE_SUFFIX=_debug /Applications/foo.app

do run that app using debug libraries -- whether the libraries are found in frameworks or as standard libraries.

The reality is that this feature may or not work as advertised.  In my testing, one needs the OSX system debug libraries installed, and all dependency libraries must use the same suffix for everything to work.  Of course, the last OSX with system debug libraries was 10.5 (just confirmed this, at least from developer.apple.com); I don't use 10.7 yet, so maybe they are available for it by now?

Your issue is with which library is picked to use in the .pc file.  When one installs "qt4-mac +debug", both the release and debug libraries are installed, as ${prefix}/lib/libQt*.dylib and ..../libQt*_debug.dylib .

Now, if you use QMake to do the building, you can specify to use DEBUG, or RELEASE (or, RELEASE_AND_DEBUG) -- and QMake will go off and figure out how to best do linking for you.  E.g., if only the release library is available, it will use that; if both debug and release are available, it will pick the release unless the debug is explicitly specified.  If just the debug is available, it will use that one.

The .pc file does indeed specify to use the release library -- which is installed even when +debug is specified.  Thus, at least in theory, one can set DYLD_IMAGE_SUFFIX to select the _debug library.

So, really, the .pc file is correct for what we're doing with qt4-mac in MacPorts -- even though it seems odd.  Basically, you're supposed to know about and use OSX DYLD environment variables to manipulate which library is loaded -- no matter if/how well that works.  I've had mixed results in my testing, even when I thought everything was correctly configured & such.

The bottom line when installing both release and debug is that there is no perfect answer to how a .pc file should be written.  In this case we're better off specifying the library without the suffix, and hoping that Apple's dyld suffix stuff works (or, gets fixed to work).

Hope this helps! - MLD

On Oct 11, 2011, at 7:37 PM, Kieran Simpson wrote:

> I'm new to MacPorts, but having come from a Linux background I'm really thankful for MP so that my favourite tools are available really easily!!

> I built qt4-mac +debug however when you do a pkg-config to check the libs to link against for say QtGui_debug, QtCore is listed rather than QtCore_debug

> I believe that this is because of an incorrect "Requires" in the pc files that specify dependencies on the non-debug versions of the libs rather than the debug versions.

> I couldn't find the pkg-config templates (find *.pc.*) in the Qt 4.7.4 distribution, so are they produced upstream by Qt or are they MacPorts contributed files?  In any case I believe this is a bug.


More information about the macports-users mailing list