首页
学习
活动
专区
圈层
工具
发布

Gsoap编译
EN

Stack Overflow用户
提问于 2015-04-26 07:55:34
回答 1查看 435关注 0票数 1

我正在尝试编写一个简单的hello world gsoap示例。我也包括了http_get插件。当我使用以下方法编译时:

代码语言:javascript
复制
g++ RestService.cpp soapC.cpp soapRestServiceSoap12Service.cpp -o server.exe -lgsoap++

我得到了这些错误:

代码语言:javascript
复制
    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

下面是我的代码

代码语言:javascript
复制
#define soapRestServiceSoap12Service_H
#include "soapH.h"
#include "httpget.h"
#include "httpget.c"
class SOAP_CMAC RestServiceSoap12Service : public soap
{ public:
        /// Constructor
        RestServiceSoap12Service();
        /// Constructor with copy of another engine state
        RestServiceSoap12Service(const struct soap&);
        /// Constructor with engine input+output mode control
        RestServiceSoap12Service(soap_mode iomode);
        /// Constructor with engine input and output mode control
        RestServiceSoap12Service(soap_mode imode, soap_mode omode);
        /// Destructor frees all data
        virtual ~RestServiceSoap12Service();
        /// Initializer used by constructor
        virtual void RestServiceSoap12Service_init(soap_mode imode, soap_mode omode);
        /// Create a copy
        virtual RestServiceSoap12Service *copy();
        /// Force close connection (normally automatic)
        virtual int soap_close_socket();
        /// Return sender-related fault to sender
        virtual int soap_senderfault(const char *string, const char *detailXML);
        /// Return sender-related fault with SOAP 1.2 subcode to sender
        virtual int soap_senderfault(const char *subcodeQName, const char *string, const char *detailXML);
        /// Return receiver-related fault to sender
        virtual int soap_receiverfault(const char *string, const char *detailXML);
        /// Return receiver-related fault with SOAP 1.2 subcode to 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 to stream
        virtual void soap_stream_fault(std::ostream&);
 /// Put fault into buffer
        virtual char *soap_sprint_fault(char *buf, size_t len);
#endif
        /// Disables and removes SOAP Header from message
        virtual void soap_noheader();
        /// Run simple single-thread iterative service on port until a connection error occurs (returns error code or SOAP_OK), use this->bind_flag = SO_REUSEADDR to rebind for a rerun
        virtual int run(int port);
        /// Bind service to 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 this request (returns error code or SOAP_OK)
        virtual int serve();
        /// Used by serve() to dispatch a 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 Get Handler
        //virtual int http_get_handler(soap *_soap);

        int Execute();


        private:
        struct soap objSoap;

};
#endif
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-22 15:59:32

我假设RestService.cppsoapRestServiceSoap12Service.cpp的头中都有#include soapRestServiceSoap12Service.h,所以在httpget.c中有一些函数的双重定义。您可以检查here是否有类似的问题。

最好不要在头文件中包括.cpp.c文件。我想您可以尝试删除#include "httpget.c"中的soapRestServiceSoap12Service.cpp,然后在编译中添加httpget.c源文件。

例如:

代码语言:javascript
复制
g++ httpget.c RestService.cpp soapC.cpp soapRestServiceSoap12Service.cpp -o server.exe -lgsoap++
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29875139

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档