Search code examples
c++windowsmingwgsoap

How to compile gSoap with ssl enabled on windows?


I am trying to build gSoap binaries with ssl support. I have downloaded the latest gSoap and binaries for WIN32 openssl from this website: http://slproweb.com/products/Win32OpenSSL.html

According to the gSoap documentation, I have to compile using the standard procedure with the DWITH_OPENSSL option enabled. I think the most natural option would be tu use minGW, but I have little experience with this tool. When I try this, (and after applying this patch I am left with two missing libraries a link time: -lssl and -lcrypto.

I guess I have to add a -L option to the compiling directive, but I dont see any libssl or libcrypto (should it be .a or .lib ?) in the openssl lib folder. Must I recompile these too or am I missing something ?


Solution

  • Ok I finally made it, here are the different steps I used :

    1. First, I had to rebuild openssl with mingw since the static libraries are not shipped with the binaries shipped by Shining Light Production. I put the openssl folder in c:/openssl/

    2. Then, in stdsoap2.h, I changed line 2247 to :

      #if defined(WIN32) && !defined(__MINGW32__)
      #define soap_strtoll _strtoi64
      #else
      # define soap_strtoll strtoll
      #endif
      
      #if defined(WIN32) && !defined(__MINGW32__)    
      # define soap_strtoull _strtoui64
      #else
      # define soap_strtoull strtoull
      #endif
      
    3. In the configure file:

      • I removed all occurence of -DWITH_GZIP and -lz.
      • I added the -lws2_32 linker option (support for winsocket I think) Those changes in the configure file are in lines 7338-7347 :

        WSDL2H_EXTRA_FLAGS="-DWITH_GNUTLS"
        WSDL2H_EXTRA_LIBS="-lgnutls -lgcrypt -lgpg-error"
        SAMPLE_SSL_LIBS="-lgnutls -lgcrypt -lgpg-error"
        WSDL2H_SOAP_CPP_LIB="libgsoapssl++.a"
        else
        { echo "$as_me:$LINENO: result: no" >&5
        echo "${ECHO_T}no" >&6; }
        WSDL2H_EXTRA_FLAGS="-DWITH_OPENSSL"
        WSDL2H_EXTRA_LIBS="-lssl -lcrypto -lws2_32"
        SAMPLE_SSL_LIBS="-lssl -lcrypto -lws2_32"
        
    4. I ran configure in mingw adding the proper LDFLAGS and CXXFLAGS, namely :

      LDFLAGS+=" -L/c/openssl/ -L/c/MinGW/lib/" CXXFLAGS+=" -I/c/openssl/include/" ./configure
      
    5. I ran make and crossed my finger!