From: Ray T. <rth...@li...> - 2002-04-20 05:20:11
|
I am trying to use MinGW to compile and link a dll for use with a Java JNI class. JNI expects to find the unmangled symbol for each native method supported in the dll. The way I understand it, the --add-stdcall-alias switch to ld is supposed to generate and export these symbols in a dll. I have tried passing this option to ld via gcc (see command below) but it doesn't seem to be adding the unmangled symbols as advertised. The command I'm using for gcc is: gcc -shared -Wl,--add-stdcall-alias -o NativeStuff.dll NativeStuff.c This works okay and generates a dll but the dll does not have the unmangled symbols. The nm utility shows the following (passed through grep to filter out the uninteresting noise): c:\projects\nativestuff> nm NativeStuff.dll | grep Java 10001068 T _Java_NativeStuff_initTest@8 10001080 T _Java_NativeStuff_fullCycleTest@8 (BTW, I tried 'nm -C' too and it yields the same report.) The JNI (javah) generated header file declares Java_NativeStuff_initTest and Java_NativeStuff_fullCycleTest without the leading underscore or the trailing @#. What I expected after adding --add-stdcall-alias was two more symbols in the dll. When the Java program is run against the dll, the resulting UnsatisfiedLinkError confirms that the symbols are not found. Can anyone tell me what I'm doing wrong? Is gcc or ld just broken? -R |