PDA

View Full Version : How to static link in 4.6. on Mac OS 10.5?



Markus
6th February 2010, 00:09
Hello All,

I just upgraded from 4.4 to 4.6 and my app does not contain the static libs anymore.
My .pro file contains this line which worked in 4.4:

CONFIG += static

I found some hint in the web:

QMAKE_LFLAGS += -static

but that generates a liker error: ld_classic: can't locate file for: -lcrt0.o
I am using the commercial version (qt-sdk-mac-commercial-2010.01.dmg).

Any suggestions?
Markus

axeljaeger
6th February 2010, 10:33
I guess 4.6 uses the "cocoa" backend. It is not possible to link statically against the cocoa-backend. Check whether this is the case by checking that any other Qt app compiled against that Qt links against "AppKit" and if this is the case, recompile Qt to use the "carbon" backend. Use this for static linking. Keep in mind that carbon is the old way and cocoa is the way to go. Make friends with the fact that you will not be able to use static linking any longer in the near future (As soon as the carbon backend gets dropped).

Markus
6th February 2010, 22:22
Hallo Axel,

I downloaded the source and compiled with -static. That works, except now I don't get TIFF and JPEG support.
Does TIFF and JPEG not work with static?

In case of Cocoa and dynamic linking, how do I deploy the needed libs?

Thanks
Markus
p.s. Grüße an meine alte Heimat :)

axeljaeger
6th February 2010, 22:24
The problem with static linking and image formats is that image formats in Qt are usually plugins and plugins do not work with static. Search for Q_IMPORT_PLUGIN in the Qt docs to see how to embed the image formats into your application.

Regarding cocoa and distribution:

Use the macdeployqt-utility. It comes with the Qt distribution.