6

How do I make apps smaller with qmake and macdeployqt?

I have set QT = core gui in the projects .pro file and run qmake and macdeployqt on the resulting app.

The problem is that the program is bundling QtNetwork, QtScript, QtSvg etc. I've tried setting QT -= network script svg (and then make clean, rm -rf *.app, qmake, make).

In total the app is 32 MB.

.pro file:

TEMPLATE = app
TARGET = throw
DEPENDPATH += .
INCLUDEPATH += .
CONFIG += x86_64 release
QT = core gui

unix {
    CONFIG += link_pkgconfig
    PKGCONFIG += glib-2.0
}

# Input
SOURCES += main.cpp

# Headers
HEADERS += throw.h

RESOURCES += throw.qrc

ICON = throw.png

mac {
    QMAKE_INFO_PLIST = Info.plist
    ICON = throw.icns
}
demonplus
  • 5,613
  • 12
  • 49
  • 68
Daniel O
  • 4,607
  • 6
  • 44
  • 52
  • 1
    IMHO, Qt apps should use a wrapper that looks for the Qt framework and, if not found, downloads and installs it into Library/Frameworks or ~/Library/Frameworks. Whether it's 30 or 70 MB, it's unreasonable to have a separate copy of Qt for every single applications. I don't know why the Qt guys never implemented such a solution. – LaC Jul 06 '11 at 16:33
  • I concur with @LaC. However, I'd like to suggest making a pkg setup that is small, and which then downloads the needed components as necessary. The pkg setup has the power to do a pre-install and post-install setup script, and even run at an administrator level account privilege if you want. – Volomike Nov 25 '15 at 08:54

2 Answers2

4

This is a great article about (re)building Qt statically and dynamically to reduce its size considerably: Building Qt Static (and Dynamic) and Making it Small with GCC, Microsoft Visual Studio, and the Intel Compiler

While this is talking about Qt in the windows context, it does give some good insight into how one would go about compiling for minimal size.

jsherer
  • 910
  • 6
  • 8
1

You could strip the binary afterwards in a post-build step. The Qt libraries themselves are shared by default.

spraff
  • 32,570
  • 22
  • 121
  • 229
  • 1
    Doesn't macdeployqt strip the binaries ? You must use the option -no-strip to not strip binaries which indicates that it is the default. – koan Jul 11 '11 at 12:08