Using Java / JNI on Cygwin

前端 未结 3 925
灰色年华
灰色年华 2020-12-12 01:59

I am entering into Java world just now. I am facing problem when I try to compile sample program for Calling C from Java.

I wanted to try the sample code for JNI (W

相关标签:
3条回答
  • 2020-12-12 02:21

    The InOnIt page uses -mno-cygwin. If you want Cygwin functionality, then you'll want http://elliotth.blogspot.com/2005/08/porting-jni-code-to-win32-with-cygwin.html. Terminator's moved since that was written. The crux of the source you'd want for a Cygwin-safe Java launcher is now at https://github.com/software-jessies-org/jessies/blob/master/salma-hayek/native/all/java-launcher/java-launcher.cpp.

    0 讨论(0)
  • 2020-12-12 02:28

    I couldn't get JNI to work with Cygwin's g++ -- that induces a dependency on cygwin1.dll, which clashes with the JNI mechanism, causing a crash. The -mno-cygwin flag is no longer supported. But using /bin/x86_64-w64-mingw32-g++.exe fixed the problem for me.

    0 讨论(0)
  • 2020-12-12 02:46

    Ensure that your native library is really loaded by adding a try/catch block around the System.loadLibrary() call to catch the UnsatifiedLinkError Exception if your library could not be found. If that doesn't work post your error, "it return aborted" isn't very helpful. Also, you defined the native print method with a void return type, yet you have a return statement. Either remove that or let the method actually return something.

    0 讨论(0)
提交回复
热议问题