c++ - Gsoap compilation -
i trying write simple hello world gsoap sample. have included http_get
plugin also. when compile using :
g++ restservice.cpp soapc.cpp soaprestservicesoap12service.cpp -o server.exe -lgsoap++
i follwing errors :
soaprestservicesoap12service.cpp:(.text+0x0): multiple definition of `soap_encode_string' /tmp/cci3th4n.o:restservice.cpp:(.text+0x0): first defined here /tmp/cc9vrcvb.o: in function `soap_decode_string': soaprestservicesoap12service.cpp:(.text+0x138): multiple definition of `soap_decode_string' /tmp/cci3th4n.o:restservice.cpp:(.text+0x138): first defined here /tmp/cc9vrcvb.o: in function `http_get': soaprestservicesoap12service.cpp:(.text+0x162c): multiple definition of `http_get' /tmp/cci3th4n.o:restservice.cpp:(.text+0x5fe): first defined here /tmp/cc9vrcvb.o: in function `query_val': soaprestservicesoap12service.cpp:(.text+0x141a): multiple definition of `query_val' /tmp/cci3th4n.o:restservice.cpp:(.text+0x3ec): first defined here /tmp/cc9vrcvb.o: in function `query_key': soaprestservicesoap12service.cpp:(.text+0x148e): multiple definition of `query_key' /tmp/cci3th4n.o:restservice.cpp:(.text+0x460): first defined here /tmp/cc9vrcvb.o: in function `query': soaprestservicesoap12service.cpp:(.text+0x150c): multiple definition of `query' /tmp/cci3th4n.o:restservice.cpp:(.text+0x4de): first defined here /tmp/cc9vrcvb.o: in function `soap_get_connect': soaprestservicesoap12service.cpp:(.text+0x152c): multiple definition of `soap_get_connect' /tmp/cci3th4n.o:restservice.cpp:(.text+0x4fe): first defined here /tmp/cc9vrcvb.o:(.rodata+0xc7): multiple definition of `http_get_id' /tmp/cci3th4n.o:(.rodata+0x13): first defined here
below code
#define soaprestservicesoap12service_h #include "soaph.h" #include "httpget.h" #include "httpget.c" class soap_cmac restservicesoap12service : public soap { public: /// constructor restservicesoap12service(); /// constructor copy of engine state restservicesoap12service(const struct soap&); /// constructor engine input+output mode control restservicesoap12service(soap_mode iomode); /// constructor engine input , output mode control restservicesoap12service(soap_mode imode, soap_mode omode); /// destructor frees data virtual ~restservicesoap12service(); /// initializer used constructor virtual void restservicesoap12service_init(soap_mode imode, soap_mode omode); /// create copy virtual restservicesoap12service *copy(); /// force close connection (normally automatic) virtual int soap_close_socket(); /// return sender-related fault sender virtual int soap_senderfault(const char *string, const char *detailxml); /// return sender-related fault soap 1.2 subcode sender virtual int soap_senderfault(const char *subcodeqname, const char *string, const char *detailxml); /// return receiver-related fault sender virtual int soap_receiverfault(const char *string, const char *detailxml); /// return receiver-related fault soap 1.2 subcode sender virtual int soap_receiverfault(const char *subcodeqname, const char *string, const char *detailxml); /// print fault virtual void soap_print_fault(file*); #ifndef with_lean /// print fault stream virtual void soap_stream_fault(std::ostream&); /// put fault buffer virtual char *soap_sprint_fault(char *buf, size_t len); #endif /// disables , removes soap header message virtual void soap_noheader(); /// run simple single-thread iterative service on port until connection error occurs (returns error code or soap_ok), use this->bind_flag = so_reuseaddr rebind rerun virtual int run(int port); /// bind service port (returns master socket or soap_invalid_socket) virtual soap_socket bind(const char *host, int port, int backlog); /// accept next request (returns socket or soap_invalid_socket) virtual soap_socket accept(); /// serve request (returns error code or soap_ok) virtual int serve(); /// used serve() dispatch request (returns error code or soap_ok) virtual int dispatch(); /// /// service operations (you should define these): /// /// web service operation 'helloworld' (returns error code or soap_ok) virtual int helloworld(_ns1__helloworld *ns1__helloworld, _ns1__helloworldresponse *ns1__helloworldresponse); /// web service operation 'openaccountbalanceinquiry' (returns error code or soap_ok) virtual int openaccountbalanceinquiry(_ns1__openaccountbalanceinquiry *ns1__openaccountbalanceinquiry, _ns1__openaccountbalanceinquiryresponse *ns1__openaccountbalanceinquiryresponse); ///http handler //virtual int http_get_handler(soap *_soap); int execute(); private: struct soap objsoap; }; #endif
i'm assuming both restservice.cpp
, soaprestservicesoap12service.cpp
has #include soaprestservicesoap12service.h
in header have double definition of functions in httpget.c
. can check here similar issue.
it practice not include .cpp
or .c
files in header files. guess can try remove #include "httpget.c"
in soaprestservicesoap12service.cpp
, in compilation, add httpget.c
source file.
e.g.
g++ httpget.c restservice.cpp soapc.cpp soaprestservicesoap12service.cpp -o server.exe -lgsoap++
Comments
Post a Comment