From: Earnie B. <ear...@ya...> - 2003-01-20 10:47:32
|
Mo DeJong wrote: > Hi all > > I recently was able to link to a Java VM lib file using mingw and I figured > others might want to see this post so they don't end up wasting time like I did. > I was using mingw 1.1, msys 1.0.8, and IBM JDK 1.3 for Win32. > > The problem I was running into looked like this: > > gcc -o jni.exe -I../../ibmjdk13/include ../../ibmjdk13/lib/jvm.lib jni.c > c:\windows\TEMP\ccn1jhgb.o(.text+0x17):jni.c: undefined reference to `_imp__JNI_GetCreatedJavaVMs@12' > > If you do some searching on the web, you might come across info like > the following: > > http://www.inonit.com/cygwin/jni/invocationApi/archive.html > > This page states that you need to create your own .a file and link > to that instead of the .lib file that comes with the JDK. Perhaps this > was an issue in older versions of mingw, but this actually had > nothing to do with the problem. > Yes, early versions of bin utils didn't like to find .lib files. > What actually fixed it, was to put the .lib file after the .c file on > the compile line. > > gcc -o jni.exe -I../../ibmjdk13/include jni.c ../../ibmjdk13/lib/jvm.lib > It is known that command line order matters when placing objects for linking. > The above command compiled and linked just fine. I know, I know, > it was a silly mistake. I hope this post keeps others from making > the same mistake. > IIRC it should work like this as well: gcc -o jni.exe -I../../ibmjdk13/include jni.c -L../../ibmjdk13/lib -ljvm Earnie |