Deploy library with Qt Creator plugin on Mac



  • Have custom library which should be deployed with my Qt Creator plugin:

    myproject.pro

    TEMPLATE = subdirs
    
    # sub-project names
    SUBDIRS += \
            MyLibrary \
            MyPlugin
    
    # where to find the sub projects - give the folders
    MyLibrary.file = lib/MyLibrary/MyLibrary.pro
    MyPlugin.file = src/MyPlugin.pro
    
    # what subproject depends on others
    MyPlugin.depends = MyLibrary
    
    CONFIG += ordered
    

    MyLibrary project file contains line to deploy it

    mylibrary.pro

    ...
    isEmpty(DESTDIR): DESTDIR = $${IDE_BUILD_TREE}/lib/qtcreator/plugins
    ...
    

    Plugin created according Qt guidelines and above works fine in Linux and should work fine in Windows. Linking to the library works as follows:

    MyPlugin.pro

    ...
    mac|unix|win32: LIBS += -L$${IDE_BUILD_TREE}/lib/qtcreator/plugins/ -lMyLibrary
    ...
    

    However on Mac plugin deployed differently to bundle: $${IDE_BUILD_TREE}/bin//Qt Creator.app/Contents/PlugIns/ and the plugin appeared in different directory with library. However even if I put the built library to the bundle manually I get an error on QTC start:

    .../qt-creator-debug/bin/Qt
    Creator.app/Contents/PlugIns/libMyPlugin_debug.dylib: Can't load
    library .../qt-creator-debug/bin/Qt
    Creator.app/Contents/PlugIns/libMyPlugin_debug.dylib:
    (dlopen(.../qt-creator-debug/bin/Qt
    Creator.app/Contents/PlugIns/libMyPlugin_debug.dylib, 133): Library
    not loaded: libMyLibrary.1.dylib Referenced from:
    .../qt-creator-debug/bin/Qt
    Creator.app/Contents/PlugIns/libMyPlugin_debug.dylib Reason: image
    not found)

    How to deploy library with QtC plugin correctly on Mac? Documentation says nothing about.


  • Lifetime Qt Champion

    @Aleksey_K said in Deploy library with Qt Creator plugin on Mac:

    Creator.app/Contents/PlugIns/libMyPlugin_debug.dylib Reason: image
    not found)

    Hi

    What do you get if your run otool -L on libMyPlugin_debug.dylib ?



  • @SGaist

    otool -L libMyPlugin_debug.dylib 
    libMyPlugin_debug.dylib:
    	@rpath/PlugIns/libMyPlugin_debug.dylib (compatibility version 4.6.0, current version 0.0.0)
    	libMyLibrary.1.dylib (compatibility version 1.0.0, current version 1.0.0)
    	@rpath/PlugIns/libCore_debug.dylib (compatibility version 4.6.0, current version 0.0.0)
    	@rpath/Frameworks/libAggregation_debug.4.dylib (compatibility version 4.6.0, current version 4.6.1)
    	@rpath/Frameworks/libExtensionSystem_debug.4.dylib (compatibility version 4.6.0, current version 4.6.1)
    	@rpath/Frameworks/libUtils_debug.4.dylib (compatibility version 4.6.0, current version 4.6.1)
    	@rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.10.0, current version 5.10.1)
    	@rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.10.0, current version 5.10.1)
    	@rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.10.0, current version 5.10.1)
    	/System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0)
    	/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
    	@rpath/QtTest.framework/Versions/5/QtTest (compatibility version 5.10.0, current version 5.10.1)
    	/System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 58286.31.2)
    	/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1450.15.0)
    	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 50.0.0)
    	@rpath/QtConcurrent.framework/Versions/5/QtConcurrent (compatibility version 5.10.0, current version 5.10.1)
    	/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
    	/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
    	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
    	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
    

  • Lifetime Qt Champion

    The libMyLibrary.1.dylib entry is too short, it's missing where it should be getting found.



  • @SGaist said in Deploy library with Qt Creator plugin on Mac:

    The libMyLibrary.1.dylib entry is too short, it's missing where it should be getting found.

    What do You mean? Could You elaborate please? Content of qt-creator-debug/lib/qtcreator/plugins/ is:

    • libMyLibrary.1.0.0.dylib
    • libMyLibrary.1.0.dylib
    • libMyLibrary.1.dylib - which is symbolic link to libMyLibrary.1.0.0.dylib
    • libMyLibrary.dylib


  • @SGaist said in Deploy library with Qt Creator plugin on Mac:

    The libMyLibrary.1.dylib entry is too short, it's missing where it should be getting found.

    1. What should be added to .pro file to add path to the library? Why it works in Linux/Windows and fails on Mac?
    2. How to deploy libMyLibrary.*.dylib to the bundle correctly? I tried to get some lines from qtcreatorplugin.pri with no luck.

  • Lifetime Qt Champion

    IIRC it's QMAKE_RPATHDIR.



  • @SGaist said in Deploy library with Qt Creator plugin on Mac:

    IIRC it's QMAKE_RPATHDIR.

    Thanks, need to try. Here is an example how to use it: https://stackoverflow.com/a/25538188/630169. The only question remains: how to deploy the library to the bundle or correct path (good if it works on all platforms) if it is built first before the plugin?


  • Lifetime Qt Champion

    The library should go in the Frameworks folder of the application. Then rpath of the plugin should point to @rpath/Frameworks so it can find the library there.



  • @SGaist, could You provide an example please - fixed mylibrary.pro? Thanks!



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