2

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 ?

jww
  • 97,681
  • 90
  • 411
  • 885
Ernest_Galbrun
  • 2,514
  • 3
  • 21
  • 33

3 Answers3

2

Yes, as I know if you use minGW 1st off install openssl and after that add path + flag like in followed example:

gcc -I/include/
-I/local/include
-L/local/lib
     -o download_file download_file.c  -llibcurl -lcurl  

Here I compile basic C file.

Or if you run ./configure add flags like this:

LDFLAGS+="-L/local/lib -lcurl"  LIBS+=-I/local/include ....
Maxim Shoustin
  • 77,483
  • 27
  • 203
  • 225
2

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!
Ernest_Galbrun
  • 2,514
  • 3
  • 21
  • 33
  • +1 for post answer to private question. Anyways, sometimes I use MAC to compile some stuff and after copy back to Windows. `minGW` has a lot of problems but most of them have workaround – Maxim Shoustin Apr 12 '13 at 11:59
2

You can also use a bit more "native" way, ie. Visual Studio C compiler for that. However this is not very straighforward.

First, compiling openssl (valid for VS 2015 Community Edition, but I believe any 2015 will do):

  • download openssl sources, unzip to some folder
  • download PERL for windows (either ActivePerl or Straberry Perl - this one is free) and install
  • open "Open Visual Studio 2015 Tools Command Prompt" from menu start
  • cd to openssl uncompressed source folder

Run following commands there (this set is using version w/o assembbler):

perl Configure VC-WIN32 no-asm --prefix=c:\some\openssl\dir
ms\do_ms
nmake -f ms\ntdll.mak
nmake -f ms\ntdll.mak test - optional step
nmake -f ms\ntdll.mak install

Afterwards, you get your openssl products installed in c:\some\openssl\dir

Next, to compile gSoap based application with SSL support, you have to add following settings (All settings are done from "Project->Properties" in Visual Studio):

  • C/C++ --> General, In Additional Include Directories, add "c:\some\openssl\dir\include" folder to the list
  • C/C++ --> Command Line, in the box "Additional Options", type: /DWITH_OPENSSL
  • Linker --> Input, Additional Dependencies: add "c:\some\openssl\dir\lib\libeay32.lib" and "c:\some\openssl\dir\lib\sskeay32.lib" to the list

If you have generated your classes using wsdl2h.exe and soapcpp2.exe tools, you are almost done. Verify, that your stdsoap2.cpp file has those lines:

#include <openssl\ssl.h>
#include <openssl\rsa.h>

If not, you can add them just after first #ifdef WITH_OPENSSL

That was all for mine project. I could compile with VC2015 and run/debug like any other app.

Good luck.

Marek
  • 81
  • 1
  • 4
  • 1
    I don't think this answers his question. His very first sentence is "I am trying to build gSoap binaries with ssl support", but your answer concerns how to compile an application with gSoap and SSL. He needs to build the gsoap binaries (ie: soapcpp2.exe and wsdl2h.exe) because the binaries that are distributed with gsoap don't have SSL support for Windows (unfortunately). For example, http://www.onvif.org/onvif/ver10/wsdl/devicemgmt.wsdl is located on an SSL server, so if you call wsdl2h.exe with that, it will fail saying SSL/TLS is not supported. – Ph0t0n Feb 20 '17 at 02:22