我下载了 gsoap 2.8.14,使用以下命令配置和安装:
./configure --disable-ssl --enable-samples --enable-debug
make
make install
我试图编译 gsoap 示例“hello”。所以我从示例中获取了 wsdl 文件并执行了以下操作:
wsdl2h -s -o hello.h h.wsdl
soapcpp2 hello.h
我将生成的文件复制到一个新的 eclipse c++ 项目中,并排除了 soapClientLib.cpp 和 soapServerLib.cpp,因为我收到了类似
的错误multiple definition of .....
然后我创建了一个 helloserver.cpp,内容如下:
#include "soapH.h"
#include "Service.nsmap"
int main()
{
return soap_serve(soap_new);
}
int __ns1__hello(struct soap *soap, char* helloReq, char* &helloResponse)
{
return SOAP_OK;
}
当我在 eclipse 中构建时,我收到一个错误:
...soapServer.cpp:77 undefined reference to __ns1__hello(soap*,_ns2_hello*, _ns__helloResponse*)
当我追踪到 soapServer.cpp 时,这一行出现错误:
soap->error=__ns1_hello(soap,soap_tmp___ns1_hello.ns2__hello,&ns2__helloResponse);
为什么我会收到这个错误?我正在使用来自 gsoap 的示例 hello wsdl
最佳答案
正如您从错误消息(和 soapServer.cpp 代码)中看到的那样,您应该编写一个函数
int __ns1__hello(struct soap *soap,
_ns2_hello* helloReq,
_ns__helloResponse* helloResponse)
{
return SOAP_OK;
}
不是你写的函数。
关于c++ - 编译 gsoap 示例 hello 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16435727/