[SOLVED] Assimp so loading on Linux does not work

Started by mudlee, May 11, 2018, 18:47:53

Previous topic - Next topic

mudlee

I get this exception. On OSX everything is fine. Also, in the log you can see, that the nanovg (and the others) loads fine.

What can be the problem?

[LWJGL] Loading library (system): lwjgl_nanovg
[LWJGL] 	Using SharedLibraryLoader...
[LWJGL] 	Found at: /tmp/lwjglmudlee/3.1.6-build-14/liblwjgl_nanovg.so
[LWJGL] 	Loaded from org.lwjgl.librarypath: /tmp/lwjglmudlee/3.1.6-build-14/liblwjgl_nanovg.so
[LWJGL] Loading library: assimp
[LWJGL] 	Using SharedLibraryLoader...
[LWJGL] 	Found at: /tmp/lwjglmudlee/3.1.6-build-14/libassimp.so
java.lang.NullPointerException
	at org.lwjgl.system.Checks.check(Checks.java:99)
	at org.lwjgl.system.Pointer$Default.<init>(Pointer.java:52)
	at org.lwjgl.system.SharedLibrary$Default.<init>(SharedLibrary.java:18)
	at org.lwjgl.system.linux.LinuxLibrary.<init>(LinuxLibrary.java:19)
	at org.lwjgl.system.APIUtil.apiCreateLibrary(APIUtil.java:124)
	at org.lwjgl.system.Library.loadNative(Library.java:329)
	at org.lwjgl.system.Library.loadNative(Library.java:313)
	at org.lwjgl.system.Library.loadNative(Library.java:235)
	at org.lwjgl.assimp.Assimp.<clinit>(Assimp.java:1859)
	at com.intermetto.engine.util.ModelLoader.loadFromOBJ(ModelLoader.java:40)
	at com.intermetto.engine.util.ModelCache.lambda$get$0(ModelCache.java:10)
	at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1138)
	at com.intermetto.engine.util.ModelCache.get(ModelCache.java:10)
	at com.intermetto.game.Tower.<clinit>(Tower.java:8)
	at com.intermetto.game.Scene.onStart(Scene.java:46)
	at com.intermetto.engine.gamestate.GameStateObservers.lambda$onStart$0(GameStateObservers.java:82)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1380)
	at com.intermetto.engine.gamestate.GameStateObservers.onStart(GameStateObservers.java:82)
	at com.intermetto.engine.Engine.run(Engine.java:52)
	at java.base/java.lang.Thread.run(Thread.java:844)
[LWJGL] 	libassimp.so not found in java.library.path=/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib

spasi

Could you please try the 3.1.7 snapshot?

mudlee

[LWJGL] Version: 3.1.7 build 3
[LWJGL] 	 OS: Linux v3.10.0-693.21.1.el7.x86_64
[LWJGL] 	JRE: 9.0.4 amd64
[LWJGL] 	JVM: Java HotSpot(TM) 64-Bit Server VM v9.0.4+11 by Oracle Corporation
[LWJGL] Loading library (system): lwjgl
[LWJGL] 	Using SharedLibraryLoader...
[LWJGL] 	Extracting: file:/home/mudlee/.m2/repository/org/lwjgl/lwjgl/3.1.7-SNAPSHOT/lwjgl-3.1.7-20180419.175656-4-natives-linux.jar!/liblwjgl.so
[LWJGL] 	Loaded from org.lwjgl.librarypath: /tmp/lwjglmudlee/3.1.7-build-3/liblwjgl.so
[LWJGL] MemoryUtil accessor: MemoryAccessorUnsafe
[LWJGL] Warning: Failed to instantiate memory allocator: org.lwjgl.system.jemalloc.JEmallocAllocator. Using the system default.
[LWJGL] MemoryUtil allocator: StdlibAllocator
[LWJGL] Loading library: glfw
[LWJGL] 	Using SharedLibraryLoader...
[LWJGL] 	Extracting: file:/home/mudlee/.m2/repository/org/lwjgl/lwjgl-glfw/3.1.7-SNAPSHOT/lwjgl-glfw-3.1.7-20180419.175436-4-natives-linux.jar!/libglfw.so
[LWJGL] 	Loaded from org.lwjgl.librarypath: /tmp/lwjglmudlee/3.1.7-build-3/libglfw.so
[LWJGL] Loading library (system): lwjgl_opengl
[LWJGL] 	Using SharedLibraryLoader...
[LWJGL] 	Extracting: file:/home/mudlee/.m2/repository/org/lwjgl/lwjgl-opengl/3.1.7-SNAPSHOT/lwjgl-opengl-3.1.7-20180419.175640-4-natives-linux.jar!/liblwjgl_opengl.so
[LWJGL] 	Loaded from org.lwjgl.librarypath: /tmp/lwjglmudlee/3.1.7-build-3/liblwjgl_opengl.so
[LWJGL] Loading library: libGL.so.1
[LWJGL] 	libGL.so.1 not found in org.lwjgl.librarypath=/tmp/lwjglmudlee/3.1.7-build-3
[LWJGL] 	Loaded from system paths: /usr/lib64/nvidia/libGL.so.1
[LWJGL] Java 9 optimizations enabled
[LWJGL] Loading library (system): lwjgl_nanovg
[LWJGL] 	Using SharedLibraryLoader...
[LWJGL] 	Extracting: file:/home/mudlee/.m2/repository/org/lwjgl/lwjgl-nanovg/3.1.7-SNAPSHOT/lwjgl-nanovg-3.1.7-20180419.175543-4-natives-linux.jar!/liblwjgl_nanovg.so
[LWJGL] 	Loaded from org.lwjgl.librarypath: /tmp/lwjglmudlee/3.1.7-build-3/liblwjgl_nanovg.so
[LWJGL] Loading library: assimp
[LWJGL] 	Using SharedLibraryLoader...
[LWJGL] 	Extracting: file:/home/mudlee/.m2/repository/org/lwjgl/lwjgl-assimp/3.1.7-SNAPSHOT/lwjgl-assimp-3.1.7-20180419.175503-4-natives-linux.jar!/libassimp.so
Disconnected from the target VM, address: '127.0.0.1:41266', transport: 'socket'
Exception in thread "GAME_LOOP_THREAD" java.lang.UnsatisfiedLinkError: Failed to dynamically load library: /tmp/lwjglmudlee/3.1.7-build-3/libassimp.so(error = null)
	at org.lwjgl.system.linux.LinuxLibrary.loadLibrary(LinuxLibrary.java:32)
	at org.lwjgl.system.linux.LinuxLibrary.<init>(LinuxLibrary.java:19)
	at org.lwjgl.system.APIUtil.apiCreateLibrary(APIUtil.java:124)
	at org.lwjgl.system.Library.loadNative(Library.java:332)
	at org.lwjgl.system.Library.loadNative(Library.java:316)
	at org.lwjgl.system.Library.loadNative(Library.java:235)
	at org.lwjgl.assimp.Assimp.<clinit>(Assimp.java:1896)
	at com.intermetto.engine.util.ModelLoader.loadFromOBJ(ModelLoader.java:40)
	at com.intermetto.engine.util.ModelCache.lambda$get$0(ModelCache.java:10)
	at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1138)
	at com.intermetto.engine.util.ModelCache.get(ModelCache.java:10)
	at com.intermetto.game.Tower.<clinit>(Tower.java:8)
	at com.intermetto.game.Scene.onStart(Scene.java:46)
	at com.intermetto.engine.gamestate.GameStateObservers.lambda$onStart$0(GameStateObservers.java:82)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1380)
	at com.intermetto.engine.gamestate.GameStateObservers.onStart(GameStateObservers.java:82)
	at com.intermetto.engine.Engine.run(Engine.java:52)
	at java.base/java.lang.Thread.run(Thread.java:844)

spasi

I cannot reproduce this. Which Linux distribution are you using? Also, please post the output of: ldd libassimp.so

mudlee

Its CentOS7.

I saw in a different thread that removing runtime scope from natives might help, but it does not here.

Output (I extracted the .so file from the built jar):
./libassimp.so: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by ./libassimp.so)
./libassimp.so: /lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by ./libassimp.so)
./libassimp.so: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./libassimp.so)
	linux-vdso.so.1 =>  (0x00007ffea999b000)
	libz.so.1 => /lib64/libz.so.1 (0x00007fd2afb8a000)
	librt.so.1 => /lib64/librt.so.1 (0x00007fd2af982000)
	libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fd2af679000)
	libm.so.6 => /lib64/libm.so.6 (0x00007fd2af377000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fd2af161000)
	libc.so.6 => /lib64/libc.so.6 (0x00007fd2aed9d000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fd2aeb81000)
	/lib64/ld-linux-x86-64.so.2 (0x000055d61fc9a000)

mudlee

I might found the problem, but on the lwjgl.org its the same.

In the pom.xml I declare assimp like this:
<dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-assimp</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-assimp</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>${lwjgl.natives}</classifier>
        </dependency>


On lwjgl.org the auto generated pom uses the same two dependency, but its a little bit weird.

spasi

The next snapshot is likely going to fix this. The current binary has been compiled with an ABI and a glibc dependency that is not supported out of the box on CentOS. Even though the versions are quite old, I couldn't find a realistic solution that would be convenient for most users*.

You could probably update libstdc++ on your system, but please don't, so that we can verify that the next snapshot has actually solved the problem.

* I'm not at all an expert on deploying portable native applications on Linux. If anyone has any related feedback, please reply here or contact me directly. I'm currently reverting all Linux binaries to be built with GCC 4.8 (3.1.6 was built with GCC 6, current snapshot with GCC 7).

mudlee

Okay, reply here when the snapshot is available and I'll try it out. CentOS is not a bleeding edge OS I agree, but at least it does not die every month :)

spasi

Actually, you don't have to wait for the next snapshot. You can download the updated Assimp from the LWJGL build browser (navigate to /nightly/linux/x64/ and click on Download next to libassimp.so). Use -Dorg.lwjgl.assimp.libname=<path_to_libassimp.so> to make sure the new binary is used by LWJGL.

spasi

LWJGL 3.1.7 snapshot 4 is available, Assimp and some other bindings affected by the same issue should now work on CentOS.

mudlee

Quote from: spasi on May 18, 2018, 22:09:55
LWJGL 3.1.7 snapshot 4 is available, Assimp and some other bindings affected by the same issue should now work on CentOS.

You mean 3.1.7 snapshot build 6, right? :)
Anyways, its working, so thanks Spasi!