How To Compile JNI DLL Using GCC Under Cygwin With MinGW Tools

With Swig


Blah, blah, blah...


Install it. Make sure you get all of the devlopment stuff that seems appopriate (gcc, libc, headers, mingw).


Make your .i file, then enter swig -java yourdotifile.i at the cygwin prompt.


Write your C file, or don't, SWIG will create plenty. You'll need at least the .h and the .lib or .dll files of the dll your wrappin'. I had trouble with the lib, so I used the dll.

In the below code, I was compiling against the CEUTIL.DLL used in Windows CE ActiveSync as a convenient abstraction of the ActiveSync registry entries. I added a symlink from /cygdrive/c/Program\ Files/java/j2sdk1.4 to /usr/java to simplify my references to the java directory.
gcc -Wall -mrtd -mno-cygwin -I/usr/java/include -I/usr/java/include/win32 -I/usr/include/w32api -shared ceutil.c ceutil_wrap.c -Wl,--add-stdcall-alias,-lceutil,-L/bin -o CEUtilWrapper.dll
The important parts of the above code include: