I am trying to create a dll in cygwin for use with jni. I have successfully achieved this for a simple "hello world" type program using the following command:
gcc -mno-cygwin -Wl,--add-stdcall-alias -shared -o myDll.dll myNativeCode.c However I would like to create my dll without using the -mno-cygwin option as my c code relies on additional C libraries which when included causes the above command to produce a large number of errors involving the libraries I am using: /usr/local/lib/libpbc.a(libpbc_la-pairing.o): In function `pairing_init_inp_gene ric': /home/me/pbc_build/pbc-0.4.11/ecc/pairing.c:80: undefined reference to `___asse rt' /home/me/pbc_build/pbc-0.4.11/ecc/pairing.c:81: undefined reference to `___asse rt' /home/me/pbc_build/pbc-0.4.11/ecc/pairing.c:147: undefined reference to `___get reent' /usr/local/lib/libpbc.a(libpbc_la-pairing.o): In function `pairing_init_inp_buf' . . . . . . /usr/local/lib/libgmp.a(assert.o):assert.c:(.text+0x29): undefined reference to `___getreent' /usr/local/lib/libgmp.a(assert.o):assert.c:(.text+0x4b): undefined reference to `___getreent' /usr/local/lib/libgmp.a(assert.o):assert.c:(.text+0x98): undefined reference to `___getreent' /usr/local/lib/libgmp.a(doprntf.o):doprntf.c:(.text+0x483): undefined reference to `__imp___ctype_' collect2: ld returned 1 exit status ( I have just given the start and end of the errors produced ) I have looked at every bit of information on -mno-cygwin, building dlls in cygwin and jni but nothing has helped although I now believe the problem lies with the fact that i did not install my libraries for mingw but for cygwin. If I could create my dll without the -mno-cygwin option I think it would solve my problem, I have tried with no success to do this. When I try this everything appears to be fine ( i.e. I receive no error messages ) but when I run my java code ( which calls the native c code ) it hangs, this happens even for the most basic "hello world" ap. My code is as follows: main.java: public class main { static { System.loadLibrary( "theNativeMethod" ); } public static void main( String args[] ) { AClassWithNativeMethods c = new AClassWithNativeMethods(); c.theNativeMethod(); } } AClassWithNativeMethods.java: public class AClassWithNativeMethods { public native void theNativeMethod(); public void aJavaMethod() { theNativeMethod(); } } AClassWithNativeMethods.h: /* DO NOT EDIT THIS FILE - it is machine generated */ #include <jni.h> /* Header for class AClassWithNativeMethods */ #ifndef _Included_AClassWithNativeMethods #define _Included_AClassWithNativeMethods #ifdef __cplusplus extern "C" { #endif /* * Class: AClassWithNativeMethods * Method: theNativeMethod * Signature: ()V */ JNIEXPORT void JNICALL Java_AClassWithNativeMethods_theNativeMethod (JNIEnv *, jobject); #ifdef __cplusplus } #endif #endif theNativeMethod.c: #include <stdio.h> #include "AClassWithNativeMethods.h" JNIEXPORT void JNICALL Java_AClassWithNativeMethods_theNativeMethod( JNIEnv* env, jobject thisObj ) { printf( "Hello JNI World\n" ); } I used the following to compile and run my java code: javac AClassWithNativeMethods.java main.java javah -jni AClassWithNativeMethods java main I would really appreciate any help in producing a dll which works and doesnt use the -mno-cygwin option. Or any other suggestions Thanks :) -- View this message in context: http://www.nabble.com/Creating-a-dll-in-cygwin-for-use-with-jni-without--mno-cygwin-tf4238762.html#a12060945 Sent from the Cygwin Users mailing list archive at Nabble.com. -- 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/