Packaging files in with the Qt project file 4.8

  • Hi there,

    I'm porting an application from mobile to desktop Qt 4.8 and I have a bunch of image and audio files that are packaged with the application and installed via the project file.

    So for example under Symbian in the project file I had:

    @music.files = sounds/music/*
    music.path = /sounds/music #appends to private automatically
    DEPLOYMENT += music@

    Which I then accessed through the code via:

    @ QString musicName = QApplication::applicationDirPath() + "/sounds/music/TitleMenu.mp3";
    iMusicMediaSourceA = new Phonon::MediaSource(musicName);@

    On other platforms such as Sailfish I used a similar approach with the INSTALLS keyword in place of DEPLOYMENT.

    However, I'm now working on Desktop - specifically Windows, but will be porting to Linux and Mac later, and this doesn't seem to work. Can anyone point me in the right direction for how to include these files in the build?

    This is with Qt 4.8

    Many thanks.

  • Moderators

    Use QRC (Qt Resource files) - it will work the same on all platforms and does not reuqire any .pro file magic.

  • Thank you, I've tried this but unfortunately it's added about 60MB to the resource file and now the project fails to compile:

    @15:48:39: Starting: "Q:\Qt\qtcreator-2.8.1\bin\jom.exe"
    q:\Qt\4.8.5\bin\qmake.exe -spec ..\Qt\4.8.5\mkspecs\win32-msvc2010 CONFIG+=declarative_debug -o Makefile ..\PuzzleStones\
    Q:\Qt\qtcreator-2.8.1\bin\jom.exe -f Makefile.Debug
    cl -c -nologo -Zm200 -Zc:wchar_t- /Zm1900 -Zi -MDd -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQ_OS_PC=1 -DQT_DLL -DQT_PHONON_LIB -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"..\Qt\4.8.5\include\QtCore" -I"..\Qt\4.8.5\include\QtGui" -I"..\Qt\4.8.5\include\QtOpenGL" -I"..\Qt\4.8.5\include\phonon" -I"..\Qt\4.8.5\include" -I"..\Qt\4.8.5\include\ActiveQt" -I"..\Qt\4.8.5\include\phonon_compat" -I"debug" -I"..\PuzzleStones" -I"." -I"..\Qt\4.8.5\mkspecs\win32-msvc2010" -Fodebug\ @C:\Users\Duncan\AppData\Local\Temp\qrc_PuzzleStones.obj.3252.94.jom
    cl : Command line warning D9025 : overriding '/Zm200' with '/Zm1900'
    debug\qrc_PuzzleStones.cpp(1165642) : fatal error C1060: compiler is out of heap space
    jom: Q:\build-PuzzleStones-Desktop-Debug\Makefile.Debug [debug\qrc_PuzzleStones.obj] Error 2
    jom: Q:\build-PuzzleStones-Desktop-Debug\Makefile [debug] Error 2@

    Any idea how to fix this?

  • Moderators

    Wow, that is impressive :) You can split the resources into several smaller files. There will be no difference at runtime (QRC prefix and all will continue to work the same), and the compiler should stay within it's limits :)

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.