Plugins on MacOS??
-
I have been trying for quite some time now to get my app working on MacOS with the plugins that I have created. I have tried everything that I could think of with the location of the plugins, the settings to be configured with the install_name_tool etc but no success...
Who is willing to have a look at this? You can download the app from https://modeltech.org/download/dfm/dfm.macos.zip and the two plugins named libbasictools.dylib and libsdf3.dylib are in /Contents/PlugIns. You can check whether any plugins are loaded by checking the dfm -> About dfm menu.
And yes, I have tried macdeployqt but that does not find my core library libdfmcore.1.dylib which I have to manually put in (in this case) /Contents/Libraries and to manually fix the settings using the install_name_tool to get it to work (without this library, nothing works).
Your help is very much appreciated!
-
Hi.... i know this problem ...
macdeployqt show only inside the QTDIR for lib... pluginI use a workground to make a symlink to QTDIR/lib so macdeployqt can take lib & relink inside bundle mac..
if (UNIX OR APPLE) if (EXISTS ${SIGNALAPPBUILD}) message("2- RELINK SHARED LIB IF EXIST ${SIGNALAPPBUILD} BUNDLE LIB PREPARE ") if (APPLE) FILE(GLOB inlibs RELATIVE "${DIR_LIBTARGET}" "${DIR_LIBTARGET}/libqt_*") elseif(UNIX) FILE(GLOB inlibs RELATIVE "${DIR_LIBTARGET}" "${DIR_LIBTARGET}/libqt_*") endif() FOREACH(infileName ${inlibs}) set(LIBFULLEXIST ${DIR_LIBTARGET}/${infileName} ) set(LIBVIRTUALQT ${DIR_LIBQT5}/${infileName} ) if (EXISTS ${LIBVIRTUALQT}) file(REMOVE ${LIBVIRTUALQT}) endif() message("FOR -> RELINK FILE ${LIBFULLEXIST} bundle ") install_symlink( ${LIBFULLEXIST} ${LIBFULLEXIST} ) ENDFOREACH(infileName) endif() endif()
But now run..
https://sourceforge.net/projects/oasidoc/In bundle ./otool say... libdfmcore.1.dylib is loaded...
otool -L dfm dfm: @executable_path/../Libraries/libdfmcore.1.dylib (compatibility version 1.0.0, current version 1.0.0) @executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.9.0, current version 5.9.2) @executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui (compatibility version 5.9.0, current version 5.9.2) @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore (compatibility version 5.9.0, current version 5.9.2) /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) @executable_path/../Frameworks/QtXml.framework/Versions/5/QtXml (compatibility version 5.9.0, current version 5.9.2) /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)
-
Thanks for sharing. I will dive into your approach to get macdeployqt to work.
For now, I did it all manually. The otool output you listed is not produced by macdeployqt but set manually by me - macdeployqt would probably use @rpath instead of @executable_path. Anyway, the problem remains in that the about box should look like what is shown below. The problem is that I do not get that to work when not running my app from QtCreator...
-
It took a while, but I have now solved this problem so let me share the solution that I found. I did a combination of the following three things to made it work:
- I needed a single cdUp() for the deployment situation as opposed to the 3x cdUp() which is necessary when running from Qt Creator (as it is explained here http://doc.qt.io/archives/qt-4.8/qt-tools-plugandpaint-example.html but on http://doc.qt.io/archives/qt-4.8/deployment-mac.html it says to use only 1x cdUp())
- I was lead to believe that the argument for QDir::cd() would be case insensitive on MacOS based on the referred documentation. Instead, I now used 'PlugIns' instead of 'plugins' to use the standard directory in the app bundle to store my plugins in. I did so because using cd in a Terminal also required using 'PlugIns' instead of 'plugins'. On the other hand, when running from QtCreator, it should be 'plugins' as that is the subdirectory that QtCreator creates when building. So, here is a second difference between running from QtCreator and when deploying
- I not only applied install_name_tool to my executable to fix the library references but I also applied it to my plugin libraries. I made sure to use @executable_path references only to my libdfmcore and also to the Qt framework libraries (so, no @rpath references as generated by a build from QtCreator or by macdeployqt)
If you wish to inspect my solution in more detail, you can have a look at https://modeltech.org/download/dfm/dfm.macos.zip