godot-kotlin-jvm icon indicating copy to clipboard operation
godot-kotlin-jvm copied to clipboard

[Export/OSX]JRE is not well embedded

Open piiertho opened this issue 3 years ago • 5 comments

Currently OSX export is buggy. It generates a dmg, with a jre folder side to it. This cause trouble because app cannot find jre folder:

**WARNING**: Godot-JVM: Godot-JVM: No embedded jvm found on path: jre/lib/server/libjvm.dylib!
   At: modules/kotlin_jvm/src/jni/jvm_loader.cpp:59:get_jvm_lib_path() - Godot-JVM: Godot-JVM: No embedded jvm found on path: jre/lib/server/libjvm.dylib!
**WARNING**: Godot-JVM: Godot-JVM: You really should embedd a jre in your game with jlink! See the documentation if you don't know how to do that
   At: modules/kotlin_jvm/src/jni/jvm_loader.cpp:61:get_jvm_lib_path() - Godot-JVM: Godot-JVM: You really should embedd a jre in your game with jlink! See the documentation if you don't know how to do that

Also, speaking of OSX, with silicon we should be able to make universal application, so that application runs as well on arm or intel. This would need to embbed two jre in export.

piiertho avatar May 28 '21 15:05 piiertho

I've done a little experimentation, and I've discovered some workarounds to get the app to still run, despite these limitations.

  • First, in the Godot export, you need to disable the hardened runtime in the code signature section. This is crucial because the Hardened Runtime does not allow relative loading of dynamically linked libraries for some reason.
  • You need to run the game from the Terminal and make sure you're in the directory where the jre folder exists to be able to run it. As an example, if you exported Overnight Kotlin Game.app to your Downloads folder (the jre folder should also be here):
cd ~/Downloads
./Overnight\ Kotlin\ Game.app/Contents/MacOS/Overnight\ Kotlin\ Game

It opens as expected.

alicerunsonfedora avatar Aug 13 '21 14:08 alicerunsonfedora

Editor will look at installed jvm using JAVA_HOME environnent variable. Adding it to bashrc is not enought for running out of terminal. Environnent variable should be added with launchctl command.

piiertho avatar Aug 14 '21 13:08 piiertho

Editor will look at installed jvm using JAVA_HOME environnent variable. Adding it to bashrc is not enought for running out of terminal. Environnent variable should be added with launchctl command.

@piiertho Would this affect all JAVA_HOME variables set this way, or can this be specified with each application in question?

alicerunsonfedora avatar Aug 14 '21 13:08 alicerunsonfedora

Editor will look at installed jvm using JAVA_HOME environnent variable. Adding it to bashrc is not enought for running out of terminal. Environnent variable should be added with launchctl command.

@piiertho Would this affect all JAVA_HOME variables set this way, or can this be specified with each application in question?

This will affect all apps. You can modify info.plist to add specific environment variables for app, but I don't recommand to do this way as JAVA_HOME is meant to be a development workspace setting, like we would do with Android sdk.

piiertho avatar Aug 14 '21 13:08 piiertho

Regarding exports, I made more investigations. First hardened runtime can be enabled if jre's dylibs are signed while exporting. But it seems I'm blocked between Godot and hotspot. I explained this here.

piiertho avatar Aug 29 '21 09:08 piiertho

@piiertho Can this issue be closed?

chippmann avatar Nov 17 '22 14:11 chippmann

Yes, it is fixed.

piiertho avatar Jan 14 '23 09:01 piiertho