编译 gsoap 输出文件 (onvif) 时出现问题



由于某种原因,我在尝试编译 gsoap 生成的代码时遇到了大量错误。我对使用 gsoap 很陌生,我无法弄清楚问题所在。我一直在按照这里的教程进行操作:

https://www.genivia.com/examples/onvif/index.html

注意:对于 WSDL2H.bat,WSDL 文件在本地使用,因为 GPL 版本的 Gsoap 不支持 HTTPS,因此使用 HTTPS 链接不起作用。 指向 onvif.com 的 HTTP 链接将重定向到 HTTPS 版本的链接。

wsdl2h.bat

wsdl2h.exe -O4 -P -x -o onvif.h ^
onvifver10actionengine.wsdl ^
onvifver10deviceio.wsdl ^
onvifver10display.wsdl ^
onvifver10receiver.wsdl ^
onvifver10recording.wsdl ^
onvifver10replay.wsdl ^
onvifver10search.wsdl ^
onvifver10advancedsecuritywsdladvancedsecurity.wsdl ^
onvifver10authenticationbehaviorwsdlauthenticationbehavior.wsdl ^
onvifver10credentialwsdlcredential.wsdl ^
onvifver10devicewsdldevicemgmt.wsdl ^
onvifver10eventswsdlevent.wsdl ^
onvifver10mediawsdlmedia.wsdl ^
onvifver10provisioningwsdlprovisioning.wsdl ^
onvifver10pacsaccesscontrol.wsdl ^
onvifver10pacsaccessrules.wsdl ^
onvifver10pacsdoorcontrol.wsdl ^
onvifver10schedulewsdlschedule.wsdl ^
onvifver10thermalwsdlthermal.wsdl ^
onvifver10uplinkwsdluplink.wsdl ^
onvifver20analyticswsdlanalytics.wsdl ^
onvifver20imagingwsdlimaging.wsdl ^
onvifver20ptzwsdlptz.wsdl ^
onvifver20mediawsdlmedia.wsdl

这 2 行被添加到生成的 onvif.h 中。 本教程希望您将 wsdd10.h 更改为 wsdd5.h,但我的 onvif.h 中没有 wsdd10.h 可以更改。

#import "wsse.h"
#import "wsdd5.h"

肥皂CPP2.bat

soapcpp2 -2 -j -x -C -I gsoapgsoap_2.8.91gsoap-2.8gsoapimport;gsoapgsoap_2.8.91gsoap-2.8gsoap onvif.h
soapcpp2 -a -x -L -pwsdd -I gsoapgsoap_2.8.91gsoap-2.8gsoapimport gsoapgsoap_2.8.91gsoap-2.8gsoapimportwsdd5.h

从 gsoap 库复制到源目录的文件

dom.cpp
mecevp.c, .h
smdevp.c, .h
stdsoap2.cpp, h
threads.c, h
wsaapi.c, h
wsddapi.c, h
wsseapi.cpp, h

复制到源目录的文件(由 SoapCPP2.exe 生成(

AccessRulesBinding.nsmap
ActionEngineBinding.nsmap
AdvancedSecurityServiceBinding.nsmap
AuthenticationBehaviorBinding.nsmap
CredentialBinding.nsmap
DeviceBinding.nsmap
DeviceIOBinding.nsmap
DisplayBinding.nsmap
DoorControlBinding.nsmap
ImagingBinding.nsmap
Media2Binding.nsmap
MediaBinding.nsmap
PACSBinding.nsmap
ProvisioningBinding.nsmap
PTZBinding.nsmap
PullPointSubscriptionBinding.nsmap
ReceiverBinding.nsmap
RecordingBinding.nsmap
ReplayBinding.nsmap
RuleEngineBinding.nsmap
ScheduleBinding.nsmap
SearchBinding.nsmap
soapAccessRulesBindingProxy.cpp
soapAccessRulesBindingProxy.h
soapActionEngineBindingProxy.cpp
soapActionEngineBindingProxy.h
soapAdvancedSecurityServiceBindingProxy.cpp
soapAdvancedSecurityServiceBindingProxy.h
soapAuthenticationBehaviorBindingProxy.cpp
soapAuthenticationBehaviorBindingProxy.h
soapC.cpp
soapCredentialBindingProxy.cpp
soapCredentialBindingProxy.h
soapDeviceBindingProxy.cpp
soapDeviceBindingProxy.h
soapDeviceIOBindingProxy.cpp
soapDeviceIOBindingProxy.h
soapDisplayBindingProxy.cpp
soapDisplayBindingProxy.h
soapDoorControlBindingProxy.cpp
soapDoorControlBindingProxy.h
soapH.h
soapImagingBindingProxy.cpp
soapImagingBindingProxy.h
soapMedia2BindingProxy.cpp
soapMedia2BindingProxy.h
soapMediaBindingProxy.cpp
soapMediaBindingProxy.h
soapPACSBindingProxy.cpp
soapPACSBindingProxy.h
soapProvisioningBindingProxy.cpp
soapProvisioningBindingProxy.h
soapPTZBindingProxy.cpp
soapPTZBindingProxy.h
soapPullPointSubscriptionBindingProxy.cpp
soapPullPointSubscriptionBindingProxy.h
soapReceiverBindingProxy.cpp
soapReceiverBindingProxy.h
soapRecordingBindingProxy.cpp
soapRecordingBindingProxy.h
soapReplayBindingProxy.cpp
soapReplayBindingProxy.h
soapRuleEngineBindingProxy.cpp
soapRuleEngineBindingProxy.h
soapScheduleBindingProxy.cpp
soapScheduleBindingProxy.h
soapSearchBindingProxy.cpp
soapSearchBindingProxy.h
soapStub.h
soapThermalBindingProxy.cpp
soapThermalBindingProxy.h
soapUplinkBindingProxy.cpp
soapUplinkBindingProxy.h
soapwsddProxy.cpp
soapwsddProxy.h
ThermalBinding.nsmap
UplinkBinding.nsmap
wsdd.nsmap
wsddC.cpp
wsddClient.cpp
wsddH.h
wsddServer.cpp
wsddStub.h

尝试使用 main 编译时出现 stl 错误.cpp int main(({ return 0; }

Severity    Code    Description Project File    Line    Suppression State
Error   C2059    syntax error: ';'  libOnvif    C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.22.27905includecstdint 18  
Error   C2061    syntax error: identifier 'std' libOnvif    C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.22.27905includecstdint 18  
Error   C2449    found '{' at file scope (missing function header?) libOnvif    C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.22.27905includecstdint 18  
Error   C2059    syntax error: '}'  libOnvif    C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.22.27905includecstdint 86  
Error   C2061    syntax error: identifier 'noexcept'    libOnvif    C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.22.27905includecstdlib 19  
Error   C2059    syntax error: ';'  libOnvif    C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.22.27905includecstdlib 19  
Error   C2449    found '{' at file scope (missing function header?) libOnvif    C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.22.27905includecstdlib 19  
Error   C2059    syntax error: '}'  libOnvif    C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.22.27905includecstdlib 21  
Error   C2061    syntax error: identifier 'noexcept'    libOnvif    C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.22.27905includecstdlib 27  
Error   C2059    syntax error: ';'  libOnvif    C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.22.27905includecstdlib 27  
Error   C2449    found '{' at file scope (missing function header?) libOnvif    C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.22.27905includecstdlib 27  
Error   C2059    syntax error: '}'  libOnvif    C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.22.27905includecstdlib 29  
Error   C2061    syntax error: identifier 'std' libOnvif    C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.22.27905includecstdio  29  
Error   C2059    syntax error: ';'  libOnvif    C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.22.27905includecstdio  29  
Error   C2449    found '{' at file scope (missing function header?) libOnvif    C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.22.27905includecstdio  29  
Error   C2059    syntax error: '}'  libOnvif    C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.22.27905includecstdio  87  
Error   C4233    nonstandard extension used: '__is_union' keyword only supported in C++, not C  libOnvif    C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.22.27905includetype_traits 482 
Error   C4233    nonstandard extension used: '__is_union' keyword only supported in C++, not C  libOnvif    C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.22.27905includetype_traits 485 
C:Users...liblibOnvifwsddapi.c    1703    

更新:问题可能是编译wsddC.cpp这是不需要的。以下内容适用于一组 ONVIF WSDL(示例中提到的 WSDL(:

c++ -o ipcamera -Wall -DWITH_OPENSSL -DWITH_DOM -DWITH_ZLIB 
-I. -I ~/gsoap-2.8/gsoap -I ~/gsoap-2.8/gsoap/plugin -I ~/gsoap-2.8/gsoap/custom 
main.cpp 
soapC.cpp 
wsddClient.cpp 
wsddServer.cpp 
soapAdvancedSecurityServiceBindingProxy.cpp 
soapDeviceBindingProxy.cpp 
soapDeviceIOBindingProxy.cpp 
soapImagingBindingProxy.cpp 
soapMediaBindingProxy.cpp 
soapPTZBindingProxy.cpp 
soapPullPointSubscriptionBindingProxy.cpp 
soapRemoteDiscoveryBindingProxy.cpp 
~/gsoap-2.8/gsoap/stdsoap2.cpp 
~/gsoap-2.8/gsoap/dom.cpp 
~/gsoap-2.8/gsoap/plugin/smdevp.c 
~/gsoap-2.8/gsoap/plugin/mecevp.c 
~/gsoap-2.8/gsoap/plugin/wsaapi.c 
~/gsoap-2.8/gsoap/plugin/wsseapi.c 
~/gsoap-2.8/gsoap/plugin/wsddapi.c 
-lcrypto -lssl -lz

但是,如果同时使用 WS-Security 和 WS-Discovery,并且将 wsdl2h 与选项-qNAMESPACE一起使用以使用C++命名空间,则不要将导入行添加到onvif.h而是将其删除。相反,创建一个新文件,例如ws.h两个导入行

#import "wsdd5.h"
#import "wsse.h"

分别生成插件的 WS-* 源代码:

soapcpp2 -a -x -L -pwsdd -I ~/gsoap-2.8/gsoap/import ws.h

并编译生成的源代码:

c++ -c -DSOAP_H_FILE=wsddH.h -Wall -DWITH_OPENSSL -DWITH_DOM -DWITH_ZLIB 
-I. -I ~/gsoap-2.8/gsoap -I ~/gsoap-2.8/gsoap/plugin -I ~/gsoap-2.8/gsoap/custom 
wsddC.cpp
c++ -c -DSOAP_H_FILE=wsddH.h -Wall -DWITH_OPENSSL -DWITH_DOM -DWITH_ZLIB 
-I. -I ~/gsoap-2.8/gsoap -I ~/gsoap-2.8/gsoap/plugin -I ~/gsoap-2.8/gsoap/custom 
wsddClient.cpp

您还应该以这种方式编译插件,这些插件依赖于生成的wsddH.h,并间接依赖于生成的wsddStub.h文件:

c++ -c -DSOAP_H_FILE=wsddH.h -Wall -DWITH_OPENSSL -DWITH_DOM -DWITH_ZLIB 
-I. -I ~/gsoap-2.8/gsoap -I ~/gsoap-2.8/gsoap/plugin -I ~/gsoap-2.8/gsoap/custom 
plugin/wsaapi.c
c++ -c -DSOAP_H_FILE=wsddH.h -Wall -DWITH_OPENSSL -DWITH_DOM -DWITH_ZLIB 
-I. -I ~/gsoap-2.8/gsoap -I ~/gsoap-2.8/gsoap/plugin -I ~/gsoap-2.8/gsoap/custom 
plugin/wsddapi.c
c++ -c -DSOAP_H_FILE=wsddH.h -Wall -DWITH_OPENSSL -DWITH_DOM -DWITH_ZLIB 
-I. -I ~/gsoap-2.8/gsoap -I ~/gsoap-2.8/gsoap/plugin -I ~/gsoap-2.8/gsoap/custom 
plugin/wsseapi.c

现在,您已经有了要与ONVIF应用程序结合使用的对象文件。假设onvif.h是使用 wsdl2h 生成的,执行 soapcpp2 以生成 ONVIF 代码。例如,具有选项-C(客户端(、-j(C++代理类(的客户端,以及强制使用 SOAP 1.2-2

soapcpp2 -2 -C -I ~/gsoap-2.8/gsoap/import -j -x onvif.h

要将它们全部编译在一起(请注意使用以前编译的.o文件(:

c++ -o ipcamera -Wall -DWITH_OPENSSL -DWITH_DOM -DWITH_ZLIB 
-I. -I ~/gsoap-2.8/gsoap -I ~/gsoap-2.8/gsoap/plugin -I ~/gsoap-2.8/gsoap/custom 
main.cpp 
soapAdvancedSecurityServiceBindingProxy.cpp 
soapDeviceBindingProxy.cpp 
soapDeviceIOBindingProxy.cpp 
soapImagingBindingProxy.cpp 
soapMediaBindingProxy.cpp 
soapPTZBindingProxy.cpp 
soapPullPointSubscriptionBindingProxy.cpp 
soapRemoteDiscoveryBindingProxy.cpp 
~/gsoap-2.8/gsoap/stdsoap2.cpp 
~/gsoap-2.8/gsoap/dom.cpp 
~/gsoap-2.8/gsoap/plugin/smdevp.c 
~/gsoap-2.8/gsoap/plugin/mecevp.c 
~/gsoap-2.8/gsoap/soapC.cpp 
~/gsoap-2.8/gsoap/wsddC.o 
~/gsoap-2.8/gsoap/wsddClient.o 
~/gsoap-2.8/gsoap/plugin/wsaapi.o 
~/gsoap-2.8/gsoap/plugin/wsddapi.o 
~/gsoap-2.8/gsoap/plugin/wsseapi.o 
-lcrypto -lssl -lz

重要的部分是使用-DSOAP_H_FILE=wsddH.h来编译wsddC.cppwsddClient.cppwsseapi.cwsddapi.c文件,因为这些插件需要 WS-Security 和 WS-Discovery 可序列化的类型和 API。也许这种方法有点笨拙,但在生成C++代理类时是必需的。好的一面还允许将代理类放置在C++命名空间中。

相关内容

  • 没有找到相关文章

最新更新