X-Spam-Check-By: sourceware.org Message-ID: <4637A234.A44A5BCC@dessent.net> Date: Tue, 01 May 2007 13:25:24 -0700 From: Brian Dessent X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U) MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: using Cygwin (-mno-cygwin) to JNI to a 3rd party DLL References: <84d4a6d50705011311m24edaf7dw73f40a72bc4a750e AT mail DOT gmail DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Reply-To: cygwin AT cygwin DOT com Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Pete Flugstad wrote: > But when I add the 3rd party DLL calls back in (and link against the > link lib), > everything links OK, but when I try and run it, I get an error from the JVM: > > Load Error: myJni.dll: Invalid access to memory location > java.lang.UnsatisfiedLinkError: myJni.dll: Invalid access to > memory location > at java.lang.ClassLoader$NativeLibrary.load(Native Method) > at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751) > at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1676) > at java.lang.Runtime.loadLibrary0(Runtime.java:822) > at java.lang.System.loadLibrary(System.java:993) > at com.test.jniTest.main(miniAce.java:33) You'll have to run this in a debugger to be sure, but I'd start looking at calling convention clashes, i.e. stdcall vs cdecl. This should be a function of the header files and how they declare prototypes. > I setup the same C code under MSVC and generate with that, and it works > just fine. In looking at the MSVC generated DLL, I see that it's symbol names > have an underscore '_' on the front of them, while the GCC -mno-cygwin > generated ones do not. I don't know that that matters, as when I built without > the 3rd party DLL, it still works. The name mangling when using stdcall is rather confusing, see . > I realize this may not be the right place for this question - it may > be more GCC > related than Cygwin related (especially since I'm using -mno-cygwin), > but I know the > guys who did a lot work on LD to make this work are here. I'm maybe hoping > someone here has seen this before? Alternatively, what is the right > place for this > question - the main GCC mailing list? Or maybe it's a Sun/JVM question? This is not the right list. When using -mno-cygwin you aren't using any of Cygwin, you're essentially cross compiling to MinGW. So their mailing list would probably be the right place to ask. The gcc list is *never* the right place to ask anything relating to debugging program crashes, unless you can actually identify a specific compiler bug (which it never is, 99.999% of the time.) Brian -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/