linux 下使用gsoap 编译生成onvif源代码+动态库

1.安装openssl

2.下载gsoap

3.将Makefile 与其它source置于与gsoap同级的目录下,修改makefile内的gsoap版本信息,makefile如下

# Makefile of gsoap

ARCH ?=

gsoap_vesion := gsoap-2.8

root_dir := $(shell pwd)
build_dir := $(root_dir)/$(gsoap_vesion)
install_dir := $(root_dir)/install

onvif_dir := $(root_dir)/onvif
wsdl_dir := $(root_dir)/wsdl

.PHONY: install clean
install:
	@rm -rf $(onvif_dir)
	@if [ ! -d $(install_dir) ]; then                               \
	cd $(build_dir);./configure --prefix=$(install_dir); \
	make; make install >/dev/null;                       \
	fi
	
	# generate onvif file
	@if [ ! -d $(onvif_dir) ]; then \
	rm -rf $(onvif_dir); \
	mkdir -p $(onvif_dir); \
	$(install_dir)/bin/wsdl2h -P  -x  -c -s -t \
	$(build_dir)/gsoap/typemap.dat -o onvif.h \
	http://www.onvif.org/onvif/ver10/device/wsdl/devicemgmt.wsdl \
	http://www.onvif.org/onvif/ver20/media/wsdl/media.wsdl \
	http://www.onvif.org/onvif/ver10/event/wsdl/event.wsdl \
	http://www.onvif.org/onvif/ver10/display.wsdl \
	http://www.onvif.org/onvif/ver10/deviceio.wsdl \
	http://www.onvif.org/onvif/ver20/imaging/wsdl/imaging.wsdl \
	http://www.onvif.org/onvif/ver20/ptz/wsdl/ptz.wsdl \
	http://www.onvif.org/onvif/ver10/receiver.wsdl \
	http://www.onvif.org/onvif/ver10/recording.wsdl \
	http://www.onvif.org/onvif/ver10/search.wsdl \
	http://www.onvif.org/onvif/ver10/network/wsdl/remotediscovery.wsdl \
	http://www.onvif.org/onvif/ver10/replay.wsdl \
	http://www.onvif.org/onvif/ver20/analytics/wsdl/analytics.wsdl \
	http://www.onvif.org/onvif/ver10/analyticsdevice.wsdl \
	http://www.onvif.org/ver10/actionengine.wsdl \
	http://www.onvif.org/ver10/pacs/accesscontrol.wsdl \
	http://www.onvif.org/ver10/pacs/doorcontrol.wsdl; \
	sed -i '1i #import "wsse.h"' onvif.h; \
	$(install_dir)/bin/soapcpp2 -2 -C -L -c -x -d $(onvif_dir) \
	-I$(build_dir)/gsoap:$(build_dir)/gsoap/import/:$(build_dir)/gsoap/custom/ onvif.h; \
	mv onvif.h $(onvif_dir); \
	fi
	-ls $(onvif_dir)/*.nsmap | grep -v "$(onvif_dir)/wsdd.nsmap" |xargs rm
	-mv $(onvif_dir)/wsdd.nsmap $(onvif_dir)/wsdd.h
	sed  -i 's/.*SOAP_WSA_2005$$/\/\/#define SOAP_WSA_2005/g' $(onvif_dir)/soapStub.h
	cp $(build_dir)/gsoap/dom.c $(onvif_dir)
	cp $(build_dir)/gsoap/plugin/mecevp.c $(onvif_dir)
	cp $(build_dir)/gsoap/plugin/mecevp.h $(onvif_dir)
	cp $(build_dir)/gsoap/plugin/smdevp.c $(onvif_dir)
	cp $(build_dir)/gsoap/plugin/smdevp.h $(onvif_dir)
	cp $(build_dir)/gsoap/stdsoap2.c $(onvif_dir)
	cp $(build_dir)/gsoap/stdsoap2.h $(onvif_dir)
	cp $(build_dir)/gsoap/plugin/threads.c $(onvif_dir)
	cp $(build_dir)/gsoap/plugin/threads.h $(onvif_dir)
	cp $(build_dir)/gsoap/plugin/wsaapi.c $(onvif_dir)
	cp $(build_dir)/gsoap/plugin/wsaapi.h $(onvif_dir)
	cp $(build_dir)/gsoap/plugin/wsddapi.c $(onvif_dir)
	cp $(build_dir)/gsoap/plugin/wsddapi.h $(onvif_dir)
	cp $(build_dir)/gsoap/plugin/wsseapi.c $(onvif_dir)
	cp $(build_dir)/gsoap/plugin/wsseapi.h $(onvif_dir)
	cp $(build_dir)/gsoap/custom/duration.c $(onvif_dir)
	cp $(build_dir)/gsoap/custom/duration.h $(onvif_dir)
	cp ./source/* $(onvif_dir)
	chmod 777 $(onvif_dir)/Makefile
clean:
	@test -f $(build_dir)/Makefile && make -C $(build_dir) distclean || true
	@rm -rf $(install_dir) $(onvif_dir)

4.其它source内容

main.cpp  onvif相关头文件路径根据自己的需要进行修改

/*main.cpp*/
#include <sys/socket.h>
#include "wsdd.h"
#include <iostream>
#include <sys/types.h>
#include<string>
#include<n
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
使用gSOAP生成ONVIF框架代码需要遵循以下步骤: 1. 下载gSOAP工具包并安装到本地。 2. 下载ONVIF设备WSDL文件,例如https://www.onvif.org/ver10/device/wsdl/devicemgmt.wsdl。 3. 使用gSOAP工具包中的wsdl2h工具将WSDL文件转换为头文件。 4. 使用soapcpp2工具生成ONVIF框架代码,例如: ```bash soapcpp2 -Iimport devicemgmt.h ``` 5. 在生成的代码中实现ONVIF设备的具体操作。 以下是在Linux系统中使用gSOAP生成ONVIF框架代码的示例: 1. 下载gSOAP工具包并安装到本地: ```bash wget https://sourceforge.net/projects/gsoap2/files/gSOAP/gsoap_2.8.112.zip unzip gsoap_2.8.112.zip cd gsoap-2.8 ./configure make sudo make install ``` 2. 下载ONVIF设备WSDL文件: ```bash wget https://www.onvif.org/ver10/device/wsdl/devicemgmt.wsdl ``` 3. 使用wsdl2h工具将WSDL文件转换为头文件: ```bash wsdl2h -o onvif.h devicemgmt.wsdl ``` 4. 使用soapcpp2工具生成ONVIF框架代码: ```bash soapcpp2 -Iimport onvif.h ``` 5. 在生成的代码中实现ONVIF设备的具体操作。 在生成的代码中,每个ONVIF操作都有对应的函数,例如`SOAP_FMAC5 int SOAP_FMAC6 __tds__GetDeviceInformation(struct soap* soap, _tds__GetDeviceInformation* tds__GetDeviceInformation, _tds__GetDeviceInformationResponse &tds__GetDeviceInformationResponse)`就是获取设备信息的函数。您可以在这些函数中实现具体的操作。 另外,生成的代码中还有一些辅助函数和结构体,您也可以根据需要使用它们。 例如,以下代码片段演示了如何创建一个SOAP客户端并调用`__tds__GetDeviceInformation`函数: ```c++ #include "soapDeviceBindingProxy.h" const char* endpoint = "http://192.168.1.100/onvif/device_service"; DeviceBindingProxy proxy; proxy.soap_endpoint = endpoint; _tds__GetDeviceInformation tds__GetDeviceInformation; _tds__GetDeviceInformationResponse tds__GetDeviceInformationResponse; proxy.__tds__GetDeviceInformation(&tds__GetDeviceInformation, tds__GetDeviceInformationResponse); // 处理返回值 ``` 在使用时,需要将`endpoint`替换为实际的设备IP地址和ONVIF服务端口号。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值