Equations

Friday, June 7, 2013

Building a DLL With JNI support under Windows (32bit versus 64bit)

Java provides us with JNI to link java projects with C++ code. I’m using Netbeans IDE which has a good C++ support With Cygwin tools and I needed to use a C++ implementation for multilabel graphcut optimization in one of my java projects.
The problem I encountered is the different settings needed to build a DLL library under 32bit and 64bit environments. Here is the settings I used to build under the different environments,

JNI:
Include: $jdk_home$/include ; $jdk_home$/include/win32

Win32bit:
I used the g++ compiler with the following options
-mno-cygwin -Wl,—add-stdcall-alias -shared -m32

Win64bit:
I used the x86_64-w64-mingw32-g++ compiler with the following options
-w -mno-cygwin -static -shared

No comments:

Post a Comment