- 准备工作
- 编译gsoap
- 生成onvif头文件
- 生成源文件
1、下载gsoap,地址:https://sourceforge.net/projects/gsoap2/
2、安装openssl,命令
apt install openssl libssl-dev
3、安装编译过程依赖库
apt install bison flex byacc编译gsoap
cd /root/gsoap-2.8 ./configure --prefix=/root/onvif/ make make install
编译成功后,会在/root/onvif生成gsoap目录
生成onvif头文件cd /root/onvif cp ./gsoap/share/gsoap/WS/typemap.dat .
修改typemap.dat,讲下面一行注释去掉
xsd__duration = #import "custom/duration.h" | xsd__duration
C代码
./gsoap/bin/wsdl2h -o onvif.h -P -x -c -s -t ./typemap.dat http://www.onvif.org/onvif/ver10/device/wsdl/devicemgmt.wsdl http://www.onvif.org/onvif/ver10/media/wsdl/media.wsdl http://www.onvif.org/onvif/ver10/deviceio.wsdl http://www.onvif.org/onvif/ver10/network/wsdl/remotediscovery.wsdl http://www.onvif.org/ver20/ptz/wsdl/ptz.wsdl
C++代码
./gsoap/bin/wsdl2h -o onvif.h -P -x -c++ -s -t ./typemap.dat http://www.onvif.org/onvif/ver10/device/wsdl/devicemgmt.wsdl http://www.onvif.org/onvif/ver10/media/wsdl/media.wsdl http://www.onvif.org/onvif/ver10/deviceio.wsdl http://www.onvif.org/onvif/ver10/network/wsdl/remotediscovery.wsdl http://www.onvif.org/ver20/ptz/wsdl/ptz.wsdl
在onvif开头加入
#import "wsse.h"生成源文件
C代码
./gsoap/bin/soapcpp2 -2 -x -L -C -c -d . onvif.h -I/root/gsoap-2.8/gsoap/ -I /root/gsoap-2.8/gsoap/import/ -I /root/gsoap-2.8/gsoap/plugin -I/root/gsoap-2.8/gsoap/custom
C++代码
./gsoap/bin/soapcpp2 -2 -x -L -C -c++ -d . onvif.h -I/root/gsoap-2.8/gsoap/ -I /root/gsoap-2.8/gsoap/import/ -I /root/gsoap-2.8/gsoap/plugin -I/root/gsoap-2.8/gsoap/custom
成功后,将在/root/onvif下生成 .c .cpp 和 .h文件,另外还有 .nsmap文件,几个 .nsmap内容相同,另外需要拷贝以下一些依赖代码
C代码
cd /root/gsoap-2.8/gsoap cp stdsoap2.c stdsoap2.h dom.c plugin/wsaapi.c plugin/wsaapi.h plugin/wsseapi.c plugin/wsseapi.h plugin/mecevp.c plugin/mecevp.h plugin/smdevp.c plugin/smdevp.h plugin/threads.c plugin/threads.h custom/duration.c custom/duration.h custom/struct_timeval.c custom/struct_timeval.h /root/onvif/
C++代码
cd /root/gsoap-2.8/gsoap cp stdsoap2.cpp stdsoap2.h dom.cpp plugin/wsaapi.c plugin/wsaapi.h plugin/wsseapi.cpp plugin/wsseapi.h plugin/mecevp.c plugin/mecevp.h plugin/smdevp.c plugin/smdevp.h plugin/threads.c plugin/threads.h custom/duration.c custom/duration.h custom/struct_timeval.c custom/struct_timeval.h /root/onvif/
目前C代码编译会报错,尚未解决
../onvif/libonvif.a(dom.o): In function `soap_serialize_xsd__anyType(soap*, soap_dom_element const*)': /root/publicmediaserver/src/onvif/dom.c:157: undefined reference to `soap_markelement' ../onvif/libonvif.a(dom.o): In function `out_element(soap*, soap_dom_element const*, char const*, char const*)': /root/publicmediaserver/src/onvif/dom.c:274: undefined reference to `soap_putelement' ../onvif/libonvif.a(dom.o): In function `soap_in_xsd__anyType(soap*, char const*, soap_dom_element*, char const*)': /root/publicmediaserver/src/onvif/dom.c:664: undefined reference to `soap_getelement' ../onvif/libonvif.a(dom.o): In function `soap_dup_xsd__anyType(soap*, soap_dom_element*, soap_dom_element const*)': /root/publicmediaserver/src/onvif/dom.c:838: undefined reference to `soap_dupelement' ../onvif/libonvif.a(dom.o): In function `soap_del_xsd__anyType(soap_dom_element const*)': /root/publicmediaserver/src/onvif/dom.c:881: undefined reference to `soap_delelement' collect2: error: ld returned 1 exit status



