aCuria
aCuria

Reputation: 7175

Problems compiling gsoap output files (onvif)

For some reason I get a ton of errors when trying to compile code generated by gsoap. I am quite new to using gsoap and I cant figure out the problem. I have been following the tutorial here:

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

note: for wsdl2h.bat, the wsdl files are used locally because the gpl version of gsoap does not support https, so using the https links do not work. http links to onvif.com redirects to the https version of the link.

wsdl2h.bat

wsdl2h.exe -O4 -P -x -o onvif.h ^
onvif\ver10\actionengine.wsdl ^
onvif\ver10\deviceio.wsdl ^
onvif\ver10\display.wsdl ^
onvif\ver10\receiver.wsdl ^
onvif\ver10\recording.wsdl ^
onvif\ver10\replay.wsdl ^
onvif\ver10\search.wsdl ^
onvif\ver10\advancedsecurity\wsdl\advancedsecurity.wsdl ^
onvif\ver10\authenticationbehavior\wsdl\authenticationbehavior.wsdl ^
onvif\ver10\credential\wsdl\credential.wsdl ^
onvif\ver10\device\wsdl\devicemgmt.wsdl ^
onvif\ver10\events\wsdl\event.wsdl ^
onvif\ver10\media\wsdl\media.wsdl ^
onvif\ver10\provisioning\wsdl\provisioning.wsdl ^
onvif\ver10\pacs\accesscontrol.wsdl ^
onvif\ver10\pacs\accessrules.wsdl ^
onvif\ver10\pacs\doorcontrol.wsdl ^
onvif\ver10\schedule\wsdl\schedule.wsdl ^
onvif\ver10\thermal\wsdl\thermal.wsdl ^
onvif\ver10\uplink\wsdl\uplink.wsdl ^
onvif\ver20\analytics\wsdl\analytics.wsdl ^
onvif\ver20\imaging\wsdl\imaging.wsdl ^
onvif\ver20\ptz\wsdl\ptz.wsdl ^
onvif\ver20\media\wsdl\media.wsdl

These 2 lines are added to the generated onvif.h. the tutorial expects you to change wsdd10.h to wsdd5.h, but there is no wsdd10.h in my onvif.h to change.

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

soapcpp2.bat

soapcpp2 -2 -j -x -C -I gsoap\gsoap_2.8.91\gsoap-2.8\gsoap\import;gsoap\gsoap_2.8.91\gsoap-2.8\gsoap onvif.h
soapcpp2 -a -x -L -pwsdd -I gsoap\gsoap_2.8.91\gsoap-2.8\gsoap\import gsoap\gsoap_2.8.91\gsoap-2.8\gsoap\import\wsdd5.h

files copied to source directory from gsoap library

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

files copied to source directory (generated by 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

stl errors I get when trying to compile with main.cpp being int main(){ return 0; }

Severity    Code    Description Project File    Line    Suppression State
Error   C2059    syntax error: ';'  libOnvif    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\cstdint 18  
Error   C2061    syntax error: identifier 'std' libOnvif    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\cstdint 18  
Error   C2449    found '{' at file scope (missing function header?) libOnvif    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\cstdint 18  
Error   C2059    syntax error: '}'  libOnvif    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\cstdint 86  
Error   C2061    syntax error: identifier 'noexcept'    libOnvif    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\cstdlib 19  
Error   C2059    syntax error: ';'  libOnvif    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\cstdlib 19  
Error   C2449    found '{' at file scope (missing function header?) libOnvif    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\cstdlib 19  
Error   C2059    syntax error: '}'  libOnvif    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\cstdlib 21  
Error   C2061    syntax error: identifier 'noexcept'    libOnvif    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\cstdlib 27  
Error   C2059    syntax error: ';'  libOnvif    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\cstdlib 27  
Error   C2449    found '{' at file scope (missing function header?) libOnvif    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\cstdlib 27  
Error   C2059    syntax error: '}'  libOnvif    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\cstdlib 29  
Error   C2061    syntax error: identifier 'std' libOnvif    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\cstdio  29  
Error   C2059    syntax error: ';'  libOnvif    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\cstdio  29  
Error   C2449    found '{' at file scope (missing function header?) libOnvif    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\cstdio  29  
Error   C2059    syntax error: '}'  libOnvif    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\cstdio  87  
Error   C4233    nonstandard extension used: '__is_union' keyword only supported in C++, not C  libOnvif    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\type_traits 482 
Error   C4233    nonstandard extension used: '__is_union' keyword only supported in C++, not C  libOnvif    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include\type_traits 485 
 C:\Users\...\lib\libOnvif\wsddapi.c    1703    

Upvotes: 0

Views: 1334

Answers (1)

Dr. Alex RE
Dr. Alex RE

Reputation: 1698

Update: the problem might be compiling wsddC.cpp which is not needed. The following works for a set of ONVIF WSDLs (the WSDLs mentioned in the example):

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

However, if you are using both WS-Security and WS-Discovery, and use wsdl2h with option -qNAMESPACE to use C++ namespaces, then do not add the import lines to onvif.h but remove them. Instead, create a new file say ws.h with the two import lines

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

Separately generate the WS-* source code for the plugins with:

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

and compile the generated sources with:

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

You should also compile the plugins this way, which rely on the generated wsddH.h and indirectly on the generated wsddStub.h files:

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

Now you have the object files to combine with your ONVIF application. Assuming that onvif.h is generated with wsdl2h, execute soapcpp2 to generate the ONVIF code. For example the client side with options -C (client side), -j (C++ proxy classes), and forcing SOAP 1.2 with -2:

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

To compile it all together (note the use of the previously compiled .o files):

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

The important part is to use -DSOAP_H_FILE=wsddH.h to compile the wsddC.cpp, wsddClient.cpp, wsseapi.c, and wsddapi.c files, because these plugins require the WS-Security and WS-Discovery serializable types and APIs. Perhaps this approach is a bit of a kludge, but needed when generating C++ proxy classes. On the bright side also allows the proxy classes to be placed in a C++ namespace.

Upvotes: 1

Related Questions