Search code examples
javacweb-servicesclientgsoap

gSOAP C client for accessing a Java web service


I have created a Java web service and I am trying to access this web service from a gSOAP C client:

wsdl2h -c CalculatorService.wsdl
soapcpp2 -c -C CalculatorService.h

When I try to compile the files with this:

g++ -o ClientWS.exe ClientWS.c soapC.c soapClient.c C:\gsoap-2.8.9\gsoap\stdsoap2.c -IC:\gsoap-2.8.9\gsoap -IC:\gsoap-2.8.9\gsoap\import -LC:\GNUstep\lib\libws2_32.a

I am getting many undefined reference errors, as shown below:

C:\DOCUME~1\MPERIY~1\LOCALS~1\Temp\ccvFm9ql.o:stdsoap2.c:(.text+0x188): undefined reference to sendto@24' C:\DOCUME~1\MPERIY~1\LOCALS~1\Temp\ccvFm9ql.o:stdsoap2.c:(.text+0x1b2): undefined reference tosend@16' C:\DOCUME~1\MPERIY~1\LOCALS~1\Temp\ccvFm9ql.o:stdsoap2.c:(.text+0x280): undefined reference to sendto@24' C:\DOCUME~1\MPERIY~1\LOCALS~1\Temp\ccvFm9ql.o:stdsoap2.c:(.text+0x2aa): undefined reference tosend@16' C:\DOCUME~1\MPERIY~1\LOCALS~1\Temp\ccvFm9ql.o:stdsoap2.c:(.text+0x302): undefined reference to send@16' C:\DOCUME~1\MPERIY~1\LOCALS~1\Temp\ccvFm9ql.o:stdsoap2.c:(.text+0x319): undefined reference toWSAGetLastError@0' C:\DOCUME~1\MPERIY~1\LOCALS~1\Temp\ccvFm9ql.o:stdsoap2.c:(.text+0xad2): undefined reference to recvfrom@24' C:\DOCUME~1\MPERIY~1\LOCALS~1\Temp\ccvFm9ql.o:stdsoap2.c:(.text+0xaf6): undefined reference tontohl@4' C:\DOCUME~1\MPERIY~1\LOCALS~1\Temp\ccvFm9ql.o:stdsoap2.c:(.text+0xb29): undefined reference to recv@16' C:\DOCUME~1\MPERIY~1\LOCALS~1\Temp\ccvFm9ql.o:stdsoap2.c:(.text+0xb3e): undefined reference toWSAGetLastError@0'
more errors like this...
collect2: ld returned 1 exit status

Can you provide a solution for how to link the missing files? I don't how the link and the include paths work, and where to search for libraries in C.

I have GNUstep and gSOAP in windows.


Solution

  • Try -LC:\GNUstep\lib\ -lws2_32

    g++ -o ClientWS.exe ClientWS.c soapC.c soapClient.c C:\gsoap-2.8.9\gsoap\stdsoap2.c -IC:\gsoap-2.8.9\gsoap -IC:\gsoap-2.8.9\gsoap\import -LC:\GNUstep\lib\ -lws2_32
    

    The -L gives the directory where your library is located

    the -l requests that the Link Editor add the named library to the those that are searched for references.

    When nominating the library using -l you drop the lib and suffix.