我是靠谱客的博主 飘逸鸭子,最近开发中收集的这篇文章主要介绍Ubuntu下gsoap编译onvif代码准备工作编译gsoap生成onvif头文件生成源文件,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

Linux下gsoap生成onvif客户端代码

  • 准备工作
  • 编译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

最后

以上就是飘逸鸭子为你收集整理的Ubuntu下gsoap编译onvif代码准备工作编译gsoap生成onvif头文件生成源文件的全部内容,希望文章能够帮你解决Ubuntu下gsoap编译onvif代码准备工作编译gsoap生成onvif头文件生成源文件所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(49)

评论列表共有 0 条评论

立即
投稿
返回
顶部