[Mono-dev] [Crosspost Ikvm-developers] Issues with JNI on Mono (IKVM Trunk)

Tommy Ettinger tommy.ettinger at gmail.com
Thu Jul 17 21:34:52 UTC 2014


I was recommended by the author of IKVM to ask here about my Mono
incompatibility issue.  I'm using the latest IKVM with the natives
self-compiled for Linux 64-bit (not the ones shipped with Mono, which are
years out of date).  When I run an application (that I wrote) on on Windows
(7, 64-bit), it works fine, and prints this in the Output window of Visual
Studio: http://pastebin.com/u8GkwE2P (mostly output from an App.config
trace switch, <add name="jni" value="4" />).  I am not sure how to get the
same type of trace output on Mono, especially since it isn't printed to the
console on Windows.  The issue seems to be related to JNI failing at
runtime with IKVM on Mono, so being able to have the JNI information traced
would be handy.  I am running the application on Fedora 20, AMD64 (in a VM)
with the command:
MONO_LOG_LEVEL=debug mono CommandersUnite.exe
I don't have any typemaps for DLLs, and the application loads native code
at runtime via JNI.  Could this be a problem?  I've referenced the previous
list thread below.
Thank you for your time.

---------- Forwarded message ----------
From: Jeroen Frijters <jeroen at sumatra.nl>
Date: Thu, Jul 17, 2014 at 1:06 AM
Subject: RE: [Ikvm-developers] Issues with JNI on Mono (IKVM Trunk)
To: Tommy Ettinger <tommy.ettinger at gmail.com>
Cc: "ikvm-developers at lists.sourceforge.net" <
ikvm-developers at lists.sourceforge.net>


You should really ask on the Mono list about this. I don't know enough
about Mono on Linux, but this looks seriously broken.

> -----Original Message-----
> From: Tommy Ettinger [mailto:tommy.ettinger at gmail.com]
> Sent: Wednesday, July 16, 2014 22:56
> To: Jeroen Frijters
> Cc: ikvm-developers at lists.sourceforge.net
> Subject: Re: [Ikvm-developers] Issues with JNI on Mono (IKVM Trunk)
>
> Ah, figured out how to load the config on Mono.  I think.  Unfortunately
> it gives a very different error: http://pastebin.com/GAsQyfA5 The
> App.config is here
> https://github.com/tommyettinger/CommandersUnite/blob/master/CU/CU/App.c
> onfig
>
>
> On Wed, Jul 16, 2014 at 1:30 PM, Tommy Ettinger
> <tommy.ettinger at gmail.com <mailto:tommy.ettinger at gmail.com> > wrote:
>
>
>       My last message was too long for the list, so here it is with
> pastebin links.
>       With those lines added to App.config, It gives the following output
> on Windows 7 in Visual Studio's output window (and nothing new on Mono):
>       Visual Studio output: http://pastebin.com/6Jpi5FxV
>       Mono output: http://pastebin.com/BEMyAerk
>
>       Thanks for your speedy reply on this, IKVM worked brilliantly until
> I tried to get it to run on Mono.  IKVM is a pretty incredible piece of
> software.
>
>
>       On Wed, Jul 16, 2014 at 6:01 AM, Jeroen Frijters <jeroen at sumatra.nl
> <mailto:jeroen at sumatra.nl> > wrote:
>
>
>               Hi Tommy,
>
>
>
>               Can you try enabling JNI tracing by adding the following to
> your app.config:
>
>
>
>               <system.diagnostics>
>
>               <switches>
>
>               <add name="jni" value="4" />
>
>               </switches>
>
>               </system.diagnostics>
>
>
>
>               Regards,
>
>               Jeroen
>
>
>
>               From: Tommy Ettinger [mailto:tommy.ettinger at gmail.com
> <mailto:tommy.ettinger at gmail.com> ]
>               Sent: Wednesday, July 16, 2014 14:00
>               To: ikvm-developers at lists.sourceforge.net <mailto:ikvm-
> developers at lists.sourceforge.net>
>               Subject: [Ikvm-developers] Issues with JNI on Mono (IKVM
> Trunk)
>
>
>
>               I've been struggling for the last two days to port my C#
IKVM
> application that uses the Java library libgdx to Linux.  The application
> works just fine on Windows/.NET, but something is wrong with the linking
> for JNI code AFAICT.  Using libgdx you have a choice of backends for how
> to display graphics, one of which is LWJGL and one of which is JGLFW.
> LWJGL failed on both 32- and 64-bit Linux (after I figured out how to
> get it to load its dependencies from the right folder) with an
> UnsatisfiedLinkError in
> org.lwjgl.DefaultSysImplementation.getPointerSize()I , which (in the
> LWJGL source) is a native method with no body in the .java file.
>
>
>               JGLFW failed on 64-bit Linux (haven't built it on 32-bit)
> with a different error, still in a native method:
>
>               java.lang.UnsatisfiedLinkError:
> com/badlogic/jglfw/Glfw.glfwInitJni()Z
>
>                         at cli.IKVM.Runtime.JNI$Frame.GetFuncPtr(Unknown
> Source)
>
>               I have had issues setting LD_LIBRARY_PATH on this machine (a
> VM running Fedora 20, 64-bit; the VM is run by VirtualBox on Windows 7
> 64-bit), and I believe java.library.path is unset, but the libraries are
> all in the current folder (same as the exe).  My application is open
> source and the latest code is at
> https://github.com/tommyettinger/CommandersUnite/ and the only IKVM-
> specific code is in
> https://github.com/tommyettinger/CommandersUnite/blob/master/CU/CU/GameG
> DX.cs#L478 .  I built gdx-jglfw.dll using the command:
>
>               "%IKVM_HOME%/ikvmc.exe" -target:library -out:gdx-jglfw.dll -
> sharedclassloader gdx.jar gdx-natives.jar gdx-backend-jglfw.jar gdx-
> backend-jglfw-natives.jar
>
>               where %IKVM_HOME% evaluated to the bin directory of the
> current trunk/head/master (latest) of the IKVM CVS on SourceForge (it
> actually may have been the latest nightly from the IKVM weblog, it is a
> version 8 or higher nightly).  That command was run on the libgdx 1.2.0
> binary release.  I then extracted the dll and so files from the natives
> jars, copied them into the project, and set them to copy into the
> release directory.
>
>               So my question is, is there a bug in my code, or in IKVM,
> here that can be fixed?  Does JNI work at all under Mono/Linux?
>
>
>
>               --
>
>               Thomas (Tommy) Ettinger
>
>
>
>
>
>       --
>
>       Thomas (Tommy) Ettinger
>
>
>
>
> --
>
> Thomas (Tommy) Ettinger



-- 

Thomas (Tommy) Ettinger
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20140717/2eaa06a0/attachment-0001.html>


More information about the Mono-devel-list mailing list