[SOLVED] Location of native libraries


I’m setting my first steps into multiplayer game development. At this moment I have a game client and game server running.

The server is running in a docker container, and I start the server without jme, so no class that extends from SimpleApplication.
This means that for example the extraction of native libraries isn’t included when starting the application.

I added this command in docker before starting the application:
java -cp jme3-core-3.2.2-stable.jar:jme3-desktop-3.2.2-stable.jar:jme3-bullet-native-3.2.2-stable.jar com.jme3.system.ExtractNativeLibraries Linux64 ../bin

And I see that indeed the libbulletjme.so file is extracted in the bin folder, next to the 2 startup scripts generated by gradle.

However, when I am starting the server, I get this error::

Exception in thread "main" java.lang.UnsatisfiedLinkError: com.jme3.bullet.PhysicsSpace.createPhysicsSpace(FFFFFFIZ)J
	at com.jme3.bullet.PhysicsSpace.createPhysicsSpace(Native Method)
	at com.jme3.bullet.PhysicsSpace.create(PhysicsSpace.java:243)
	at com.jme3.bullet.PhysicsSpace.<init>(PhysicsSpace.java:236)
	at org.chimpstack.jme3.es.bullet.BulletSystem.initialize(BulletSystem.java:104)
	at com.simsilica.sim.AbstractGameSystem.initialize(AbstractGameSystem.java:75)
	at com.simsilica.sim.GameSystemManager.initialize(GameSystemManager.java:114)
	at org.chimpstack.wof.server.GameServer.<init>(GameServer.java:96)
	at org.chimpstack.wof.server.Main.main(Main.java:50)

both jme3-bullet and jme3-bullet-native are on the classpath. Am I missing some other native libraries? Are the native files in the correct directory?

for completeness the folder structure of the unpacked .tar file generated by the gradle build task:

. bin
… wof-server
… wof-server.bat
… libbulletjme.so
. lib
… skipped other libraries
… jme3-bullet-3.2.2-stable.jar
… jme3-bullet-native-3.2.2-stable.jar
… jme3-core-3.2.2-stable.jar
… jme3-desktop-3.2.2-stable.jar
… jme3-es-bullet-0.1.0.jar
… jme3-networking-3.2.1-stable.jar
… jme3-terrain-3.2.2-stable.jar

The command is launched inside the bin directory, the bin directory is the working dir.

I tried:

  • setting the LD_LIBRARY_PATH="/app/wof-server/bin" variable
  • adding -Djava.library.path="/app/wof-server/bin" to the startup script
    still no luck

I do something quite similar with my server, although I extract the libraries from the jars at runtime. You need to explicitly load them via the usual System.loadLibrary() means - the system won’t automatically find and load them.

1 Like

aha! thanks for the tip, I’ll try that!

No problem! If you have more trouble with it let me know and I’ll look up how my code is doing it and provide you with some snippets.

1 Like

yep, that does seem to do the trick!

tested it quickly:

static {
    System.load(System.getProperty("user.dir") + "/libbulletjme.so");

and the application starts up without throwing an error.

edit: for further reference, this is probably the best solution:

static {
    NativeLibraryLoader.loadNativeLibrary("bulletjme", true);

This way, I don’t even have to do the extraction of the libs myself!


It’s also not that hard to detect the OS and auto-extract the right native lib from the jars. :grinning: