Search code examples
c++automakegsoap

Different behavior when automake is used to build a gSoap application


We have developed a simple C++ application using gSoap . When we use classical Makefile, everything is OK and the system works fine. But when we use GNU autotools as the build system, we encounter a strange constraint violation validation error when we call the service:

( SOAP 1.1 fault: SOAP-ENV:Client [no subcode]
"Validation constraint violation: invalid value in element 'risk'"
Detail: [no detail]

We've checked all the compile and like flags and both look the same.

Makefile.am

ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4
AUTOMAKE_OPTIONS = subdir-objects
AM_CPPFLAGS =  --pedantic -Wall -Wno-vla -Wno-unknown-pragmas -Wno-format
bin_PROGRAMS= Client Server
Client_SOURCES=card_soap_client.cpp  envC.cpp  stdsoap2.cpp  cardProxy.cpp  cardC.cpp
Client_CPPFLAGS= $(AM_CPPFLAGS) -DWITH_NONAMESPACES 
Server_SOURCES=card_soap_server.cpp  envC.cpp stdsoap2.cpp  cardService.cpp  cardC.cpp
Server_CPPFLAGS= $(AM_CPPFLAGS) -DWITH_NONAMESPACES 

Makefile

CF=-c -Wall --pedantic -Wno-vla -Wno-unknown-pragmas -Wno-format  -g -O2  -fPIC -DPIC -DWITH_NONAMESPACES 
LF =  -g -O2
all: card_soap_client.o card_soap_server.o cardProxy.o  cardService.o cardC.o envC.o stdsoap2.o
        g++ card_soap_client.o cardProxy.o   cardC.o envC.o stdsoap2.o   $(LF) -o Client
        g++  card_soap_server.o cardService.o  cardC.o envC.o  stdsoap2.o  $(LF) -o Server
cardC.o:cardC.cpp
        g++ $(CF) cardC.cpp
cardService.o:cardService.cpp
        g++ $(CF) cardService.cpp
cardProxy.o:cardProxy.cpp
        g++ $(CF) cardProxy.cpp
envC.o: envC.cpp
        g++ $(CF) envC.cpp
stdsoap2.o: stdsoap2.cpp
        g++ $(CF) stdsoap2.cpp
card_soap_client.o:card_soap_client.cpp
        g++ $(CF) card_soap_client.cpp
card_soap_server.o:card_soap_server.cpp
        g++ $(CF) card_soap_server.cpp

We've generated the service using 2.8.9 and 2.8.23 and compiled with g++-4.7. The service is generated with the following command:

soapcpp2  -i -n -qcard  -I/usr/share/gsoap/import/ interface_v1.3.1.hpp

UPDATE: The full source is available here


Solution

  • The root of the evil is the config.h file that is generated by autoconf tools. Look at CF var of your Makefile. If you add -DHAVE_CONFIG_H -I. -I.. i.e. your CF will be

    CF=-c -Wall -DHAVE_CONFIG_H -I. -I.. --pedantic -Wno-vla -Wno-unknown-pragmas -Wno-format -g -O2 -fPIC -DPIC -DWITH_NONAMESPACES

    then you will have same error as at the automake variant of compilation

    EDITED Look at soap_s2double function in the stdsoap2.cpp file. If we activate HAVE_CONFIG_H macros (via -DHAVE_CONFIG_H option) that it in turn deactivates HAVE_STRTOD macros (look stdsoap2.h file). As result we have SOAP_TYPE error (because we can't convert string value of the risk var to double). If we work without HAVE_CONFIG_H macros that we have HAVE_STRTOD active macros and therefore strtod function works succesfully and we don't have any error.

    EDITED N1

    If you add #define HAVE_STRTOD 1 string to your config.h file then all will work perfectly.