Hello Guest

Cannot load / find native libaries

  • 3 Replies
  • 2637 Views
Cannot load / find native libaries
« on: September 10, 2016, 14:19:54 »
Hi all

I refreshed my gradle projects to the latest snapshots (noticed there have been some changes re native library loading). Now, when launching my apps, the native libs seem not be able to be loaded anymore. Some debug output:

Hello LWJGL 3.0.1 build 20!
[LWJGL] Version: 3.0.1 build 20
[LWJGL]     OS: Mac OS X v10.11.6
[LWJGL]    JRE: 1.8.0_102 x86_64
[LWJGL]    JVM: Java HotSpot(TM) 64-Bit Server VM v25.102-b14 by Oracle Corporation
[LWJGL] Loading library (system): lwjgl
[LWJGL]    Extracting: file:/Users/radar/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl/3.0.1-SNAPSHOT/e14f00b58003067d48840a1015d378bf256925d1/lwjgl-3.0.1-SNAPSHOT-natives-macos.jar!/liblwjgl.dylib
[LWJGL]    liblwjgl.dylib not found in org.lwjgl.librarypath=/var/folders/m5/zl32hxhn64d4wk71ckj08xfm0000gn/T/lwjgl3577718834999344513
[LWJGL] [TLS] Failed to initialize unsafe implementation.
[LWJGL] ThreadLocalUtil state: TLState
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.lwjgl.system.MemoryAccess
   at org.lwjgl.system.Pointer.<clinit>(Pointer.java:22)
   at org.lwjgl.system.Platform.mapLibraryNameBundled(Platform.java:76)
   at org.lwjgl.glfw.GLFW.<clinit>(GLFW.java:562)
   at ch.fhnw.i4ds.comgr.HelloLWJGL.run(HelloLWJGL.java:33)
   at ch.fhnw.i4ds.comgr.HelloLWJGL.main(HelloLWJGL.java:17)

The native library is exactly in the place the loader seems to be looking for. Not sure what's happening here...

Also noticed that the native libs now seems to be extracted with a new hash on every launch, i.e. the lwjgl35777*  will change when launching again:

Hello LWJGL 3.0.1 build 20!
[LWJGL] Version: 3.0.1 build 20
[LWJGL]     OS: Mac OS X v10.11.6
[LWJGL]    JRE: 1.8.0_102 x86_64
[LWJGL]    JVM: Java HotSpot(TM) 64-Bit Server VM v25.102-b14 by Oracle Corporation
[LWJGL] Loading library (system): lwjgl
[LWJGL]    Extracting: file:/Users/radar/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl/3.0.1-SNAPSHOT/e14f00b58003067d48840a1015d378bf256925d1/lwjgl-3.0.1-SNAPSHOT-natives-macos.jar!/liblwjgl.dylib
[LWJGL]    liblwjgl.dylib not found in org.lwjgl.librarypath=/var/folders/m5/zl32hxhn64d4wk71ckj08xfm0000gn/T/lwjgl7732233640758519993
[LWJGL] [TLS] Failed to initialize unsafe implementation.
[LWJGL] ThreadLocalUtil state: TLState
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.lwjgl.system.MemoryAccess
   at org.lwjgl.system.Pointer.<clinit>(Pointer.java:22)
   at org.lwjgl.system.Platform.mapLibraryNameBundled(Platform.java:76)
   at org.lwjgl.glfw.GLFW.<clinit>(GLFW.java:562)
   at ch.fhnw.i4ds.comgr.HelloLWJGL.run(HelloLWJGL.java:33)
   at ch.fhnw.i4ds.comgr.HelloLWJGL.main(HelloLWJGL.java:17)


Any suggestions?

Cheers /Stefan


PS - just for info, my gradle script looks like this at the moment:

pply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'

repositories {
    mavenCentral()
    jcenter()
    maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}

public String getLwjglArch(String platform) {
  switch(platform.replaceAll(' ', '').toLowerCase()) {
    case ~/.*linux.*/:  return 'linux'
    case ~/.*darwin.*/: return 'macos'
    case ~/.*osx.*/:    return 'macos'
    case ~/.*win.*/:    return 'windows'
    default:            return platform
  }
}

ext {
  //lwjglVersion = "3.0.0b"
  lwjglVersion = "3.0.1-SNAPSHOT"
  lwjglArch = getLwjglArch(System.properties['os.name'])
}

dependencies {
  compile "org.lwjgl:lwjgl:$lwjglVersion"
  compile "org.lwjgl:lwjgl-glfw:$lwjglVersion"
  compile "org.lwjgl:lwjgl-opengl:$lwjglVersion"

  runtime "org.lwjgl:lwjgl:$lwjglVersion:natives-$lwjglArch"
  runtime "org.lwjgl:lwjgl-glfw:$lwjglVersion:natives-$lwjglArch"
}

*

Offline spasi

  • *****
  • 2163
    • WebHotelier
Re: Cannot load / find native libaries
« Reply #1 on: September 10, 2016, 15:56:25 »
Thanks, the problem should be fixed in build 21 with 1f0e79a.

Re: Cannot load / find native libaries
« Reply #2 on: September 10, 2016, 16:07:52 »
Perfect, thanks - I'll try with the new build when available!

Re: Cannot load / find native libaries
« Reply #3 on: September 12, 2016, 06:54:57 »
All working nicely again... Thanks for the quick fix!  :)