Topic: Help with Building wolfSSL JNI on Windows

Hi,

I've run into a number of issues trying to build the JNI package on Windows 7.  The wolfssl source I've cloned is the latest version (3.10.0). 

First, I tried the cygwin route:
$ ./confgure --enable-jni
$ make

The 'make' generates the following error messages:
...
src/crl.c:48:9: error: #error "CRL monitor only currently supported on linux or mach"
        #error "CRL monitor only currently supported on linux or mach"
         ^
src/crl.c: In function ‘FreeCRL’:
src/crl.c:143:13: error: implicit declaration of function ‘StopMonitor’ [-Werror=implicit-function-declaration]
         if (StopMonitor(crl->mfd) == 0)
             ^
src/crl.c:143:9: error: nested extern declaration of ‘StopMonitor’ [-Werror=nested-externs]
         if (StopMonitor(crl->mfd) == 0)
         ^
src/crl.c: In function ‘StartMonitorCRL’:
src/crl.c:743:41: error: ‘DoMonitor’ undeclared (first use in this function)
     if (pthread_create(&crl->tid, NULL, DoMonitor, crl) != 0) {
                                         ^
src/crl.c:743:41: note: each undeclared identifier is reported only once for each function it appears in
src/crl.c: At top level:
src/crl.c:339:12: error: ‘SignalSetup’ defined but not used [-Werror=unused-function]
static int SignalSetup(WOLFSSL_CRL* crl, int status)
            ^
src/crl.c:362:12: error: ‘SwapLists’ defined but not used [-Werror=unused-function]
static int SwapLists(WOLFSSL_CRL* crl)
            ^
cc1: all warnings being treated as errors
make[1]: *** [Makefile:3253: src/src_libwolfssl_la-crl.lo] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/home/hshim/wolfssl/wolfssl'
make: *** [Makefile:1985: all] Error 2
...

Fyi, without '--enable-jni' to 'configure,' the source builds and all the tests pass. 

Next, I used the Visual Studio Express 2013 to build the wolfssl dll (Configuration: Release, Platform: Win32).  Then in wolfssl-jni-1.3.0, I modified 'java.sh' for my cygwin environment:

----- start: modified java.sh -----
javaHome=`echo $JAVA_HOME`
javaIncludes="-I$javaHome/include -I$javaHome/include/win32"
javaLibs="-shared"
jniLibName="libwolfSSL.so"
cflags="-DHAVE_ECC -DUSE_FAST_MATH"

# create /lib directory if doesn't exist
if [ ! -d ./lib ]
then
    mkdir ./lib
fi

gcc -DWOLFSSL_DTLS -Wall -c $fpic $cflags ./native/com_wolfssl_WolfSSL.c -o ./native/com_wolfssl_WolfSSL.o $javaIncludes
gcc -DWOLFSSL_DTLS -Wall -c $fpic $cflags ./native/com_wolfssl_WolfSSLSession.c -o ./native/com_wolfssl_WolfSSLSession.o $javaIncludes
gcc -DWOLFSSL_DTLS -Wall -c $fpic $cflags ./native/com_wolfssl_WolfSSLContext.c -o ./native/com_wolfssl_WolfSSLContext.o $javaIncludes
gcc -DWOLFSSL_DTLS -Wall -c $fpic $cflags ./native/com_wolfssl_wolfcrypt_RSA.c -o ./native/com_wolfssl_wolfcrypt_RSA.o $javaIncludes
gcc -DWOLFSSL_DTLS -Wall -c $fpic $cflags ./native/com_wolfssl_wolfcrypt_ECC.c -o ./native/com_wolfssl_wolfcrypt_ECC.o $javaIncludes
gcc -Wall $javaLibs $cflags -o ./lib/$jniLibName ./native/com_wolfssl_WolfSSL.o ./native/com_wolfssl_WolfSSLSession.o ./native/com_wolfssl_WolfSSLContext.o ./native/com_wolfssl_wolfcrypt_RSA.o ./native/com_wolfssl_wolfcrypt_ECC.o -L path_to_folder_with_wolfssl.dll -lwolfssl

----- end: modified java.sh -----

However, the modified script fails; it generates a number of undefined references when linking to the wolfssl dll:
....
./native/com_wolfssl_WolfSSL.o:com_wolfssl_WolfSSL.c:(.text+0x32): undefined reference to `wolfSSL_Init'
./native/com_wolfssl_WolfSSL.o:com_wolfssl_WolfSSL.c:(.text+0x32): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `wolfSSL_Init'
./native/com_wolfssl_WolfSSL.o:com_wolfssl_WolfSSL.c:(.text+0xa7): undefined reference to `wolfTLSv1_server_method'
./native/com_wolfssl_WolfSSL.o:com_wolfssl_WolfSSL.c:(.text+0xa7): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `wolfTLSv1_server_method'
./native/com_wolfssl_WolfSSL.o:com_wolfssl_WolfSSL.c:(.text+0xc2): undefined reference to `wolfTLSv1_client_method'
./native/com_wolfssl_WolfSSL.o:com_wolfssl_WolfSSL.c:(.text+0xc2): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `wolfTLSv1_client_method'
./native/com_wolfssl_WolfSSL.o:com_wolfssl_WolfSSL.c:(.text+0xdd): undefined reference to `wolfTLSv1_1_server_method'
....

Any help in resolving this issue be greatly appreciated.

Thanks,
--Hyong

Share

Re: Help with Building wolfSSL JNI on Windows

Hi Hyong,

Thank you for reaching out to us and using the wolfSSL forums!

I regret the wolfJNI package is only supported on Linux or Mach at this time. We placed that error intentionally as a sort of "hint" to that effect. We would be happy to explore a consulting effort to port to windows if you need it right away or are unable to port it yourself.

Unfortunately there is not enough demand from the community to justify prioritizing this effort above other paid work. We always desire to support our community and are torn we can not offer to do the port immediately. I hope you can appreciate our need to prioritize work accordingly.

I have added this to the list of requested features on your behalf. To prevent any confusion on the matter I feel obligated to express there is no delivery date associated with this request and our feature request list is quite long. It may be some time before we get around to supporting wolfJNI on windows.


Warmest Regards,

Kaleb