Qt World Summit: Submit your Presentation

How to create a Bundle Library (mh_bundle) with qmake on Mac OS X?

  • Hi All,

    I'm a newbee to Qt and qmake and I like to know if it's possible to instruct qmake
    to build a "Bundle Library" (mh_bundle) under Mac OS X using the TEMPLATE
    and CONFIG variables? I already managed to make a "Dynamic Library" (mh_dylib)
    and a "Framework" (mh_dylib). If there is no direct solution, how is the best way to
    achieve this goal?

    Thank you, any help is very appreciated!

  • There is no switch in qmake directly. You can manipulate the linker flags in your .pro file like this:

    # plugin necessary because otherwise compatibility
    # version parameters are added, which are not
    # supported with bundles
    CONFIG += plugin
    QMAKE_LFLAGS_PLUGIN -= -dynamiclib
    QMAKE_LFLAGS_PLUGIN += -bundle

    You can tweak other qmake variables too, eg. for setting the name and extension of the generated file.

  • Thanks for your reply. This configuration really solved my problem.
    You mentioned that I can tweak other qmake variables for setting
    the name and extension of the generated file. I tried different ones
    but the name of the bundle library seems to have always the same
    pattern like lib[TARGET].dylib

    Do you know which qmake variables I have to use to change that?

  • You can change the extension like this:


    But I don't see a way to get rid of the lib prefix. Changing QMAKE_PREFIX_SHLIB does not work. You could add a post linking command like this:

    QMAKE_POST_LINK = mv -f $(TARGET) awesomestuff.coolPlugin

  • Hi,
    I am using qmake to create an xcode project from a .pro file. The command I am using is

    qmake -spec macx-xcode File.pro

    What settings in the .pro file should I use so that the mach-o-type is bundle in the generated XCode project. I have used all the options as suggested in this thread and more but at most I get dylib.
    If I use lib Template and lib_bundle CONFIG then I get framework after building the XCode project.

    The config suggested in this thread above only makes a dylib but does not create a bundle.


  • Sorry, I can't help with that; I never used XCode together with qmake and .pro projects.

  • Can you please help me figuring out how to compile pro file through qmake. I am sorry if this is mundane but I am using the following
    qmake File.pro -o makefilename

    The output I get is makefilename.xcodeproj which is an xcode project. How do I compile and have a make file for a pro file.

  • As posted in "this thread":http://developer.qt.nokia.com/forums/viewthread/1632/ you should do this:

    rm -rf makefilename.xcodeproj
    rm Info.plist
    qmake -spec macx-g++ File.pro

  • I've added a "Wiki page":http://developer.qt.nokia.com/wiki/Generate_Makefiles_instead_of_XCode_projects_on_Mac_OS_X too, since the question seems to pop up once in a while.

  • I know the post is quite old now, however I've a solution that works with qmake version 3.0 (and XCode 6.2):
    you should set the bundle name to the full path of your framework e.g
    QMAKE_FRAMEWORK_BUNDLE_NAME = $$PWD/Release/yourframeworkname
    note that the .framework extension is automatically added.
    When linked to the framework, an application will look for it at this full path location.
    macdeployqt could be used later to distribute your application.

Log in to reply