This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Using libmarblewidget in OSX app bundle: wrong plugins load

Tags: None
(comma "," separated)
rainbowgoblin
Registered Member
Posts
21
Karma
0
I'm developing an application for Mac OSX that uses MarbleWidget. I've got my application compiled, and it runs on my computer. However, I want to be able to distribute my application as a bundle for Mac users who won't have Qt or libmarblewidget installed, so I'm including plugins, libraries and frameworks in my application bundle. In earlier versions of my software (when I wasn't using MarbleWidget) I got this all working using macdeployqt and install_name_tool to fix my binary and libraries/plugins in the bundle so that they'd link to the copies of libraries included in the bundle. However, I'm running into problems now with libmarblewidget.

I've copied the Marble plugins to the PlugIns directory in my application bundle (bundle.app/Contents/PlugIns), in a subdirectory called marble. When I run my application with DYLD_PRINT_LIBRARIES=1 to see what's being loaded, everything looks good until the first plugin is loaded. The plugin loaded is in /Applications/Marble.app/Contents/MacOS/resources/plugins (rather than from my bundle), and it then causes Qt frameworks to be loaded from /Developer and then libmarblewidget.15.dylib to be loaded from /usr/local/lib. My guess is that the libmarblewidget.dylib that's in my bundle is loading the /Applications/Marble.app plugins. I've checked that my application is in fact loading libmarblewidget from the bundle (it is), and I've checked that /Applications/Marble.app/Contents/MacOS/resources/plugins isn't in my applications library path (it's not... checked using the QApplication::libraryPaths() function).

Is it possible to fix this?

An update: I'm fairly certain my notion that libmarblewidget.dylib is loading the plugins from /Applications. I've been looking at the source code, and it looks like there's a preprocessor directive defining MARBLE_PLUGIN_PATH in a file called config-marble.h that's hard-coded to /Applications/Marble.app/Contents/MacOS/resources/plugins (which was set up when I ran cmake while building Marble). This is used in MarbleDirs.cpp to set a value that's eventually returned in the pluginPath function, which is called in PluginManager.cpp. Lots of different source files create PluginManager objects, so I lost track at that point.
rainbowgoblin
Registered Member
Posts
21
Karma
0
I looked at the code in MarbleDirs.cpp, and discovered that the location for plugins is hard-coded into the function pluginSystemPath. So, fine, I can fix my problem by just putting the plugins into the expected location.

However, the location used for OSX bundles isn't the default location (according to the Qt documentation http://qt-project.org/doc/qt-5.0/qtdoc/qt-conf.html, that would be application.app/Contents/plugins/), and furthermore, qt.conf allows users to specify other locations. The location MarbleWidget expects is set by appending a hard-coded path to the application bundle path. Instead, maybe it should look instead at QCoreApplication::libraryPaths() to figure out what the developer has specified, or something along these lines.

I'm happy to make sure this works, and to write a patch, if someone thinks this is worthwhile. I have a couple points I'd like input on, though:

1) The default or qt.conf-specified location for plugins contains a number of subdirectories. My thought would be to create a subdirectory called marble and put the plugins in there. This isn't necessarily intuitive, but could be documented somewhere.
2) The Marble.app bundle that's created when Marble is compiled on a Mac OSX has its plugins in a somewhat different location, and this is managed by the compile-time plugin path MARBLE_PLUGIN_PATH. This is fine, I guess, but could be streamlined to follow the same sort of pattern I've described in point (1), i.e., the plugin path could be accessed via QCoreApplication::libraryPaths() (possibly appending /marble to each of the paths, and checking to see if that path exists). This might also make the plugin path more intuitive, since developers who weren't sure where plugins should be placed could check the Marble.app qt.conf file and see that its defined plugins value + marble was where plugins were found in that bundle.
3) I haven't mentioned the data directory. Data is also defined in qt.conf, but I'm not sure how to access the value. Any tips would be appreciated.

Any other thoughts?


Bookmarks



Who is online

Registered users: bancha, Bing [Bot], Evergrowing, Google [Bot], lockheed, mesutakcan, Sogou [Bot]