Trolltech Home | Qt-jambi-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-jambi-interest Archive, May 2007
UnsatisfiedLinkError: __qt_initLibrary


Message 1 in thread

Hi there,

I'm having troubles getting the new Jambi beta to run properly.
I set the path-variable and "installed" the eclipse-plugin and using eclipse, my application is working properly.
But as soon as I try starting it outside of eclipse, I get the following error:

java.lang.UnsatisfiedLinkError: __qt_initLibrary
    at com.trolltech.qt.core.QtJambi_LibraryInitializer.__qt_initLibrary(Native Method)
    at com.trolltech.qt.core.QtJambi_LibraryInitializer.<clinit>(QtJambi_LibraryInitializer.java:10)
    at com.trolltech.qt.core.QAbstractFileEngineHandler.<clinit>(QAbstractFileEngineHandler.java:12)
    at com.trolltech.qt.QtJambi_LibraryInitializer.<clinit>(QtJambi_LibraryInitializer.java:26)
    at com.trolltech.qt.QtJambiObject.<clinit>(QtJambiObject.java:29)
Exception in thread "main" 

When
I remove the automatically generated variable pointing at the
qtjambi.jar from the buildpath of my project, and insert it manually
over "add jar-file" I get the same error. So it's only working, when
using the jar over the "JAMBI_LOCATION" variable in eclipse.

I
guess it has something to do with the path-variables that need to be
set and I actually get this behaviour on two different machines.

I'm using Windows XP and set the PATH variable to the bin-directory of my jambi directory.
Also, I tried setting LD_LIBRARY_PATH to the lib-directory with no results.

On
one of the machines there's never been an other version of jambi or
even QT installed, so it can't be any old references either....
I'm
most likely just forgetting some major variable to set or something,
but bear with me, since I can't seam to figure it out on my own.

Many Thanks,
Franziska



      __________________________________  Kennt man wirklich jeden über 3 Ecken? Die Antworten gibt's bei Yahoo! Clever. www.yahoo.de/clever


Message 2 in thread

Hi, Franziska.

finphoenix13-jambi@xxxxxxxx wrote:
> java.lang.UnsatisfiedLinkError: __qt_initLibrary
>     at com.trolltech.qt.core.QtJambi_LibraryInitializer.__qt_initLibrary(Native Method)
>     at com.trolltech.qt.core.QtJambi_LibraryInitializer.<clinit>(QtJambi_LibraryInitializer.java:10)
>     at com.trolltech.qt.core.QAbstractFileEngineHandler.<clinit>(QAbstractFileEngineHandler.java:12)
>     at com.trolltech.qt.QtJambi_LibraryInitializer.<clinit>(QtJambi_LibraryInitializer.java:26)
>     at com.trolltech.qt.QtJambiObject.<clinit>(QtJambiObject.java:29)
> Exception in thread "main" 
>
> When
> I remove the automatically generated variable pointing at the
> qtjambi.jar from the buildpath of my project, and insert it manually
> over "add jar-file" I get the same error. So it's only working, when
> using the jar over the "JAMBI_LOCATION" variable in eclipse.
>   

When adding the .jar-file manually in Eclipse, you have to remember to 
also set the "Native library location" of the build path entry. You can 
find this by expanding the entry for the .jar file in the list, 
selecting "Native library location" and clicking the "Edit" button. Set 
this to bin\ directory in your Jambi installation.

> I'm using Windows XP and set the PATH variable to the bin-directory of my jambi directory.
> Also, I tried setting LD_LIBRARY_PATH to the lib-directory with no results.
>   

This is due to a bug in the Qt Jambi Beta 2. Unfortunately, loading 
libraries from the java.library.path does not work properly. There are 
several ways of fixing this problem:

1. You can pass -Dcom.trolltech.qt.library-path=path/to/jambi/bin to the 
Java executable as you run the application.
2. You can pass -Dcom.trolltech.qt.implicit-loading=false
3. You can include the path/to/jambi/bin directory in your class path as 
you run the application.
4. Qt Jambi should also automatically be able to find the native 
libraries if you are using the default structure of the Qt Jambi package 
(hence, if the classes are loaded from qtjambi.jar, and this is located 
in the root of the unzipped package, and the native libraries are 
located under path/to/jambi/bin. If you are building the package from 
source, you will have to make the same structure as in the binary 
package to get the automatic loading.

In case you are indeed building from source, I am attaching a patch 
which fixes the bug.

-- Eskil


==== com/trolltech/qt/Utilities.java#19 (text) ====
==== com/trolltech/qt/Utilities.java#19 (text) ====

@@ -100,6 +100,7 @@
                 }
             }
         } catch (Throwable e) {
+            if (VERBOSE_LOADING) System.out.println("Failed to load " + lib + " from " + env);
             return false;
         }
         return false;
@@ -119,8 +120,9 @@
         // from there.
         try {
             URL libUrl = Thread.currentThread().getContextClassLoader().getResource(lib);
-            if (libUrl == null)
+            if (libUrl == null) {
                 throw new RuntimeException("Library: '" + lib + "' could not be resolved");
+            }
 
             File tmpDir = new File(System.getProperty("java.io.tmpdir"));
             File tmpLibDir = new File(tmpDir, "QtJambi_" + QtJambi.VERSION_STRING);
@@ -153,8 +155,9 @@
                     Runtime.getRuntime().load(libraryPath);
                     if (VERBOSE_LOADING)
                         System.out.println("Loaded(" + libraryPath + ") using deploy path, as " + lib);
+                    return true;    
                 }
-                return true;
+                
             } catch (Throwable e) {
                 if (VERBOSE_LOADING)
                     e.printStackTrace();