[Interest] qt-android: How to shrink the size of Qt libraries

见良 jian_liang at cdv.com
Sat Mar 29 03:22:59 CET 2014


    Hello everyone:
    I am writing an app which is designed to run on both android and  iOS, we development our app's UI usingn Qt Quick technology. But the size of the Qt library is too big, I have to build Qt by myself (from the stable branch of git repository) to shrink size, the build command is:

DISABLED_FEATURES='
 -no-feature-TEXTODFWRITER
 -no-feature-CURSOR
 -no-feature-SHAREDMEMORY
 -no-feature-SYSTEMSEMAPHORE
 -no-feature-PROCESS
 -no-feature-DOM
 -no-feature-FILESYSTEMWATCHER
 -no-feature-FILESYSTEMITERATOR
 -no-feature-MOVIE
 -no-feature-IMAGE_HEURISTIC_MASK
 -no-feature-IMAGE_TEXT
 -no-feature-PICTURE
 -no-feature-PDF
 -no-feature-PRINTER
 -no-feature-CUPS
 -no-feature-PAINT_DEBUG
 -no-feature-BIG_CODECS
 -no-feature-FTP
 -no-feature-UDPSOCKET
 -no-feature-NETWORKPROXY
 -no-feature-SOCKS5
 -no-feature-NETWORKDISKCACHE
 -no-feature-STATEMACHINE
 -no-feature-XMLSCHEMA
'

SKIPPED_MODULES='-skip qtwebkit -skip qtwebkit-examples -skip qtquick1 -skip qt3d -skip qtjsondb -skip qtsystems -skip qtwayland -skip qtlocation'

export ANDROID_NDK_ROOT=/mnt/sda7/software/google/android/android-ndk-r9b
export ANDROID_SDK_ROOT=/mnt/sda7/software/google/android/android-sdk-linux
export ANDROID_API_VERSION=android-19
export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64

./configure --prefix=../../qt5-sdk-android-arm -xplatform android-g++ -nomake tests -nomake examples -android-ndk $ANDROID_NDK_ROOT -android-sdk $ANDROID_SDK_ROOT -android-ndk-host linux-x86_64 -android-toolchain-version 4.8 -opensource -confirm-license -no-qml-debug -no-warnings-are-errors $SKIPPED_MODULES $DISABLED_FEATURES

make -j 4
make install

$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip ../qt5-sdk-android-arm/lib/lib*.so
$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip ../qt5-sdk-android-arm/plugins/platforms/lib*.so
$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip ../qt5-sdk-android-arm/plugins/platforms/android/lib*.so
$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip ../qt5-sdk-android-arm/plugins/imageformats/lib*.so

    As you can see from the commands, I disabled many features and strip the final libraries, after all there steps the size of the libraries is:
    libQt5Core          3.3MB
    libQt5Gui            2.7MB
    libQt5Network    394.5KB

    libQt5Qml           1.8MB
    libQt5Quick        1.8MB

    libQtMultimedia  456KB

    But the size is still bigger than I have expected, Is there any way to shrink the library size even further? Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140329/07630c4c/attachment.html>


More information about the Interest mailing list