OmixVisualization / qtjambi

QtJambi is a wrapper for using Qt in Java.
http://www.qtjambi.io
Other
354 stars 40 forks source link

[BUG] java.lang.UnsatisfiedLinkError undefined symbol: _ZTIN16QNativeInterface7Private10QXcbScreenE #193

Closed januhlir closed 6 months ago

januhlir commented 6 months ago

Failure to load QtJambi libraries.

Trying to run the most basic Qt example, it fails on the fist line:

        QApplication.initialize(args);

Exception:

/home/espinosa/bin/jdk-21.0.2/bin/java -Djava.library.path=/home/espinosa/build/qt-build/qt-everywhere-src-6.6.2/build-123/qtbase/lib -javaagent:/home/espinosa/bin/idea-IC-231.9011.34/lib/idea_rt.jar=36465:/home/espinosa/bin/idea-IC-231.9011.34/bin -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath /home/espinosa/workspace2/qt-jambi-1/target/classes:/home/espinosa/.m2/repository/io/qtjambi/qtjambi/6.6.2/qtjambi-6.6.2.jar:/home/espinosa/.m2/repository/io/qtjambi/qtjambi-native-linux-x64/6.6.2/qtjambi-native-linux-x64-6.6.2.jar org.example.Main
Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/QtJambi6.6.2_6334/lib/libQtJambiGui.so.6.6.2: /tmp/QtJambi6.6.2_6334/lib/libQtJambiGui.so.6.6.2: undefined symbol: _ZTIN16QNativeInterface7Private10QXcbScreenE, version Qt_6_PRIVATE_API
    at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
    at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:331)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:197)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:139)
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2418)
    at java.base/java.lang.Runtime.load0(Runtime.java:852)
    at java.base/java.lang.Runtime.load(Runtime.java:838)
    at io.qt.internal.LibraryUtility.loadNativeLibrary(LibraryUtility.java:2408)
    at io.qt.internal.LibraryUtility.loadQtJambiLibrary(LibraryUtility.java:1990)
    at io.qt.internal.LibraryUtility.loadQtJambiLibrary(LibraryUtility.java:1813)
    at io.qt.internal.NativeUtility.loadQtJambiLibrary(NativeUtility.java:614)
    at io.qt.Utility.loadQtJambiLibrary(QtObject.java:146)
    at io.qt.QtUtilities.loadQtJambiLibrary(QtUtilities.java:115)
    at io.qt.gui.QtJambi_LibraryUtilities.<clinit>(QtJambi_LibraryUtilities.java:37)
    at io.qt.gui.QGuiApplication.<clinit>(QGuiApplication.java:13)
    at org.example.Main.main(Main.java:17)

It's run from IntelliJ, hence the javaagent bit. QtJambi s from Maven.

System

omix commented 6 months ago

This is not a bug. Either use pre-built Qt binaries from Qt installer or also build QtJambi from source based on your Qt build.

januhlir commented 6 months ago

build QtJambi from source based on your Qt build.

Unfortunately, that would not work in other distributions. I'm looking for a cross-distribution friendly solution.

pre-built Qt binaries from Qt installer

That requires Qt account and not sure if I can distribute them with my app.

I tried binaries from Flatpak, from QtCreator, from Flathub, and I got similar error. Though the Qt version there is 6.6.3 version. Flatpak/FlatHub distributed Qt would be the best solution. Truly working everywhere. I would like to eventually distribute my app through Flatpak/Flathub.

omix commented 6 months ago

The cross distro solution is to ship your software along with Qt and Jambi binaries. It doesn't matter if you ship your own builds or those of Qt installer+Maven Jambi. The license terms of Qt installer is GPL/LGPL, i.e. you can use these also for distribution according to my understanding.

The Qt builds on different Linux distros are too different to find a general solution. This is because they differ in enabled features, dependencies, used compilers and compiler versions.