我正在尝试构建我的第一个gSoap应用程序。即使是给出的calc示例也不会为我编译。我按照自述文件执行了以下操作:
使用提供的工具(wsdl2h -s -o calc.h http://www.cs.fsu.edu/~engelen/calc.wsdl
)将wsdl转换为标题
使用soapcpp2
生成的calc.h
(soapcpp2 -i calc.h
)
创建了一个新项目,添加了一个“soap”目录,并在那里复制了以下文件:calc.nsmap, soapC.cpp, soapcalcProxy.h, soapH.h, soapStub.h, stdsoap2.h, stdsoap2.cpp
写了这段代码:
#include "soap/soapcalcProxy.h"
#include "soap/calc.nsmap"
int main()
{
calcProxy service;
double result;
if (service.add(1.0, 2.0, result) == SOAP_OK)
std::cout << "The sum is " << result << std::endl;
else
service.soap_stream_fault(std::cerr);
}
试图编译
make all
Building file: ../soap/soapC.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"soap/soapC.d" -MT"soap/soapC.d" -o "soap/soapC.o" "../soap/soapC.cpp"
../soap/soapC.cpp: In function ‘int soap_out_SOAP_ENV__Reason(soap*, const char*, int, const SOAP_ENV__Reason*, const char*)’:
../soap/soapC.cpp:914:48: error: too many arguments to function ‘int soap_set_attr(soap*, const char*, const char*)’
../soap/stdsoap2.h:2384:27: note: declared here
make: *** [soap/soapC.o] Error 1
它抱怨生成的文件中的参数数量错误。我做错了什么?
答案 0 :(得分:3)
你正在混合两种不同的gSOAP释放:
1.代码生成器soapcpp2
2.包含文件soap/stdsoap2.h
(它不是生成的文件,而是gSOAP的一部分)
如果您将gsoap作为包安装,则包含文件应位于/ usr / include中。否则你应该添加&#34; -I [gSOAP include]&#34;到编译命令和&#34; -L [gSOAP lib]&#34;链接命令。
我能够使用以下命令构建你的main.cpp
mkdir soap
wsdl2h -s -o soap/calc.h http://www.cs.fsu.edu/~engelen/calc.wsdl
soapcpp2 -i soap/calc.h -d soap
g++ -o calc main.cpp soap/soapC.cpp soap/soapcalcProxy.cpp -lgsoap++