Bug 343449 - analitza QML plugin should be built as a bundle plugin and not a shared library
Summary: analitza QML plugin should be built as a bundle plugin and not a shared library
Status: REPORTED
Alias: None
Product: analitza
Classification: Frameworks and Libraries
Component: core (show other bugs)
Version: unspecified
Platform: Fink Packages macOS
: NOR normal
Target Milestone: ---
Assignee: Aleix Pol
URL: https://developer.apple.com/library/m...
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-28 11:55 UTC by Hanspeter Niederstrasser
Modified: 2021-03-09 05:23 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
patch (930 bytes, patch)
2015-02-04 00:22 UTC, Aleix Pol
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hanspeter Niederstrasser 2015-01-28 11:55:38 UTC
The analitza QML plugin (libanalitzadeclarativeplugin) is being built as a shared library. It should be built as bundles (MODULE) in the CMakeLists.txt file. 

Reproducible: Always


Actual Results:  
When built as SHARED as in the current code, libanalitzadeclarativeplugin.dylib gets installed to $PREFIX/share/qt5/qml/org/kde/analitza, but is given an install_name of $PREFIX/lib/libanalitzadeclarativeplugin.dylib. This mismatch can cause problems. It is also given a compatibility_version of 0.0.0.

Expected Results:  
Since the plugin is not supposed to be a linkable library, it should be built as MODULE in CMakeLists.txt. This also corrects the install_name/install location mismatch. The change should not have any effect on non-OS X systems

--- 8< --- 8< --- 8< --- 8< --- 8< --- 8< ---
--- analitza-14.12.1-orig/declarative/CMakeLists.txt	2015-01-05 14:24:31.000000000 -0600
+++ analitza-14.12.1/declarative/CMakeLists.txt	2015-01-28 05:49:24.000000000 -0600
@@ -5,7 +5,7 @@
         ${CMAKE_BINARY_DIR}
 )
 
-add_library(analitzadeclarativeplugin SHARED analitzadeclarativeplugin.cpp graph2dmobile.cpp analitzawrapper.cpp)
+add_library(analitzadeclarativeplugin MODULE analitzadeclarativeplugin.cpp graph2dmobile.cpp analitzawrapper.cpp)
 
 target_link_libraries(analitzadeclarativeplugin
 	Qt5::Core Qt5::Gui Qt5::Qml Qt5::Quick
 --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< ---
Comment 1 Aleix Pol 2015-01-31 18:03:59 UTC
IIRC this was done because Qt really needs the lib* prefix. Can you give it a try to your change and tell me if it worked for you?

Thanks!
Comment 2 Hanspeter Niederstrasser 2015-01-31 19:30:43 UTC
Yes, with the proposed change, the file is installed as analitzadeclarativeplugin.so (no lib prefix). However, I don't know how to go about testing whether it works or not with the non-prefix name.
Comment 3 Aleix Pol 2015-02-04 00:22:28 UTC
Created attachment 90903 [details]
patch

The change you pasted won't work, I'll attach a new one. You can test it by running kalgebramobile.

It's especially interesting sorting out this one, because many QML modules in KDE are using SHARED instead of module, this will mean we need to change them out.
Comment 4 Hanspeter Niederstrasser 2015-02-05 12:50:56 UTC
WIth no patch: libanalitzadeclarativeplugin.dylib; shared lib
With my patch: analitzadeclarativeplugin.so; module
With attachment 90903 [details]: libanalitzadeclarativeplugin.so; module

kalgebra fails with this error:
nieder $ /sw/Applications/KF5/kalgebramobile.app/Contents/MacOS/kalgebramobile 
QQmlApplicationEngine failed to load component
file:///widgets/KAlgebraMobile.qml:-1 File not found

$ ls -l /sw/lib/qt5-mac/share/kalgebramobile/plugins/widgets/KAlgebraMobile.qml
-rw-r--r--  1 root  admin  2224 Nov 12 19:59 /sw/lib/qt5-mac/share/kalgebramobile/plugins/widgets/KAlgebraMobile.qml

So I seem to also have the unrelated issue with finding .qml modules...
Comment 5 Aleix Pol 2015-02-05 13:58:44 UTC
Yes, looks like a different problem.
You'll have to see why this returns empty:
QStandardPaths::locate(QStandardPaths::DataLocation, "plugins", QStandardPaths::LocateDirectory);

Do you get this problem with all alternatives?
Comment 6 Christoph Feck 2015-02-15 10:04:28 UTC
If you can provide the information requested in comment #5, please add it.
Comment 7 Hanspeter Niederstrasser 2015-02-15 15:32:30 UTC
Sorry about the delay.  Life intruded.  Unfortunately, I'm not a programmer, so I can't write the little program to check QStandardPaths::locate(QStandardPaths::DataLocation, "plugins", QStandardPaths::LocateDirectory).  But if the code is provided, I should be able to compile it, run it, and provide the necessary feedback.
Comment 8 Aleix Pol 2015-02-16 11:59:38 UTC
Ok, you can also use the "qtpaths" tool provided by Qt, it should be something like:

$ qtpaths --locate-dirs GenericDataLocation kalgebramobile/plugins
/home/kde-devel/kde5/share/kalgebramobile/plugins
Comment 9 Hanspeter Niederstrasser 2015-02-16 12:43:59 UTC
$ qtpaths --locate-dirs GenericDataLocation kalgebramobile

$ qtpaths --locate-dirs GenericDataLocation /sw/Applications/KF5/kalgebramobile.app/Contents/MacOS/kalgebramobile

$ qtpaths --locate-dirs GenericDataLocation /sw/Applications/KF5/kalgebramobile.app/Contents/MacOS/kalgebramobile/plugins

(and to make sure qtpaths is actually working)...
$ qtpaths --display GenericDataLocation
Application Support
$ qtpaths --paths GenericDataLocation
/Users/nieder/Library/Application Support:/Library/Application Support

For kalgebramobile (comment 4), the app failed to start up a GUI and gave the "QQmlApplicationEngine failed to load component" error regardless of how the analitzadeclarativeplugin was built (kalgebramobile was rebuilt after each rebuild of analitza to make sure it was looking for the new analitzadeclarativeplugin file). The app process runs, it just doesn't display anything.
Comment 10 Aleix Pol 2015-02-16 14:54:05 UTC
So the problem seems to be that files are being installed in the wrong path. You are installing the file into:
/sw/lib/qt5-mac/share/kalgebramobile/plugins/widgets/KAlgebraMobile.qml
But then QStandardPaths reports it should be in
/sw/Applications/KF5/kalgebramobile.app/Contents/MacOS/kalgebramobile/plugins/widgets/KAlgebraMobile.qml

Now this should be figured out at CMake level.
Comment 11 Hanspeter Niederstrasser 2015-02-17 13:09:35 UTC
Unfortunately, the path /sw/Applications/KF5/kalgebramobile.app/Contents/MacOS/kalgebramobile/plugins/widgets can't exist with the current layout because the actual runtime executable inside the .app bundle is /sw/Applications/KF5/kalgebramobile.app/Contents/MacOS/kalgebramobile (file/directory collision). I renamed the executable to kalgebramobile-bin and then copied KAlgebraMobile.qml into each of the following directories with no change in the results.

/sw/Applications/KF5/kalgebramobile.app/Contents/MacOS
/sw/Applications/KF5/kalgebramobile.app/Contents/MacOS/kalgebramobile
/sw/Applications/KF5/kalgebramobile.app/Contents/MacOS/kalgebramobile/widgets
/sw/Applications/KF5/kalgebramobile.app/Contents/MacOS/kalgebramobile/plugins/widgets
/sw/Applications/KF5/kalgebramobile.app/Contents/MacOS/widgets
/sw/Applications/KF5/kalgebramobile.app/Contents/MacOS/plugins/widgets

I also copied the executable to /sw/lib/qt5-mac/bin so it would be in the same directory tree as KAlgebraMobile.qml, but again, no change.
Comment 12 Aleix Pol 2015-02-17 21:48:40 UTC
Well, maybe you want to get in touch with the kde-mac guys. I'd love to find solution to that, but it's clearly something not KAlgebra-specific.

Feel free to CC me.
Comment 13 Justin Zobel 2021-03-09 05:23:02 UTC
Thank you for the bug report.

As this report hasn't seen any changes in 5 years or more, we ask if you can please confirm that the issue still persists.

If this bug is no longer persisting or relevant please change the status to resolved.