Gsoap编译

穆尼卜(Muneeb)Zulfiqar

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

g++ RestService.cpp soapC.cpp soapRestServiceSoap12Service.cpp -o server.exe -lgsoap++

我收到以下错误:

    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

下面是我的代码

#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
塞塞米利亚

我假定这两个RestService.cppsoapRestServiceSoap12Service.cpp具有#include soapRestServiceSoap12Service.h在它们的头,所以你必须在某些功能的双重定义httpget.c您可以在此处检查类似问题。

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

例如

g++ httpget.c RestService.cpp soapC.cpp soapRestServiceSoap12Service.cpp -o server.exe -lgsoap++

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Gsoap编译

来自分类Dev

gSoap示例未编译

来自分类Dev

编译gsoap-onvif解决#错误:在此范围内未声明'M_ASN1_STRING_data'

来自分类Dev

gsoap分配简单类型

来自分类Dev

gSoap Exchange Web服务连接

来自分类Dev

gsoap和资源管理

来自分类Dev

在 linux 上安装 gsoap 失败

来自分类Dev

具有模拟功能的EWS gSoap连接

来自分类Dev

如何在Gsoap中分配C ++对象

来自分类Dev

gsoap linux c ++ / struct失败交付

来自分类Dev

gSOAP 正则表达式验证

来自分类Dev

gsoap在404错误的情况下更改响应内容类型

来自分类Dev

在Gsoap中从标题字段添加HTTP POST标题

来自分类Dev

gsoap如何在c ++模式下释放内存?

来自分类Dev

是否可以在gsoap的单独线程中执行功能?

来自分类Dev

使用gSoap时如何解释C ++中的接收数据?

来自分类Dev

使用GSOAP使用自签名证书访问服务

来自分类Dev

gSOAP:如何在响应中忽略可选元素?

来自分类Dev

gsoap在404错误的情况下更改响应内容类型

来自分类Dev

gSoap发送的响应不超过4个字节

来自分类Dev

c++ - 无法使用 HTTPS 访问 gSOAP Web 服务

来自分类Dev

在 gSoap 中使用带有 Windows 证书存储的私钥

来自分类Dev

gsoap 如何防止枚举值的下划线转换

来自分类Dev

#import:在VS 2010中无法打开文件“ soap12.h”以读取gSoap

来自分类Dev

gSoap-将请求/响应提取为XML字符串

来自分类Dev

gSoap中的soapcpp2.exe未生成C ++客户端代理头文件

来自分类Dev

如何找到gsoap服务器在哪个以太网接口上接收请求?

来自分类Dev

在gSoap服务器中执行服务器操作之前获取回调

来自分类Dev

具有SSL的简单gSoap服务器和客户端