gsoap,openssl,onvif makefile编译,undefined reference to `soap_ssl_init',errno错误号500,401等

网上关于gsoap,onvif,ssl编译的帖子已经很多,我就不多说了。直说几点别人忽视的。
stdsoap2.c,-lgsoapssl -lgsoap -lgsoapck,这4个在makefile里面只能出现一个。
首先要明白,.a静态库其实也就是.c和.h的打包文件。包含.a,也就相当于包含了众多的.h和.c.实际上仔细看。.a里面的东西跟stdsoap2.c都是一样的,
如果重复包含了。在make时候会提示重复定义的错误。
实际上包含.a也可以。我为什么要把stdsoap2.c包含进来呢。因为stdsoap2.c里面有的代码有bug,会导致程序崩溃。段错误,所以我改了stdsoap2.c的几行代码。
soap_QName2s这个函数里面,判断指针是否为空的处理
#ifdef WITH_FAST
 //miaoweijun modify
 if(soap->labbuf != NULL)
         soap->labbuf[soap->labidx > 0 ? soap->labidx - 1 : 0] = '\0';
在一个,明明已经包含了stdsoap2.c,但是还是会提示undefined reference soap_ssl_init,这个是因为,stdsoap2.c一定要配合 -DWITH_OPENSSL 选项才可以生效。
如果你明明已经定义了 -DWITH_OPENSSL ,但是还提示undefined reference,那一定是编译顺序的问题。-DWITH_OPENSSL一定要提的足够靠前(最终产生的编译命令行靠左)的位置才可以。
我最早的Makefile是这样的。#MY_LIBS   =-luuid -lgsoapssl -lgsoap -lssl  -lgsoapck -lcrypto -lz -lpthread -L$(PWD)/lib,同时代码里还有stdsoap2.c,是不行的。
最后改成这样。实际上只需要一个ssl的静态库而已。stdsoap2.c已经整合了所有需要可能用到的soap.soapssl的东西。
MY_LIBS   =-luuid -lssl  -lcrypto -lz  -lpthread -L$(PWD)/lib
onvif鉴权,取得profile,失败,可能是你nsmap.h里面缺少东西,这样可能返回错误码500,如果gsoap返回401错误,那是未鉴权的错误
SOAP_NMAC struct Namespace namespaces[] = {
        {"SOAP-ENV", "http://www.w3.org/2003/05/soap-envelope", "http://schemas.xmlsoap.org/soap/envelope/", NULL},
        {"SOAP-ENC", "http://www.w3.org/2003/05/soap-encoding", "http://schemas.xmlsoap.org/soap/encoding/", NULL},
        {"xsi", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance", NULL},
        {"xsd", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org/*/XMLSchema", NULL},
        {"wsa", "http://schemas.xmlsoap.org/ws/2004/08/addressing", NULL, NULL},
        {"wsdd", "http://schemas.xmlsoap.org/ws/2005/04/discovery", NULL, NULL},
        {"chan", "http://schemas.microsoft.com/ws/2005/02/duplex", NULL, NULL},
        {"wsa5", "http://www.w3.org/2005/08/addressing", "http://schemas.xmlsoap.org/ws/2004/08/addressing", NULL},
        {"c14n", "http://www.w3.org/2001/10/xml-exc-c14n#", NULL, NULL},
        {"ds", "http://www.w3.org/2000/09/xmldsig#", NULL, NULL},
        {"saml1", "urn:oasis:names:tc:SAML:1.0:assertion", NULL, NULL},
        {"saml2", "urn:oasis:names:tc:SAML:2.0:assertion", NULL, NULL},
        {"wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd", NULL, NULL},
        {"xenc", "http://www.w3.org/2001/04/xmlenc#", NULL, NULL},
        {"wsc", "http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512", NULL, NULL},
        {"wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd", NULL},
        {"xmime", "http://tempuri.org/xmime.xsd", NULL, NULL},
        {"xop", "http://www.w3.org/2004/08/xop/include", NULL, NULL},
        {"tt", "http://www.onvif.org/ver10/schema", NULL, NULL},
        {"wsrfbf", "http://docs.oasis-open.org/wsrf/bf-2", NULL, NULL},
        {"wstop", "http://docs.oasis-open.org/wsn/t-1", NULL, NULL},
        {"wsrfr", "http://docs.oasis-open.org/wsrf/r-2", NULL, NULL},
        {"tdn", "http://www.onvif.org/ver10/network/wsdl", NULL, NULL},
        {"tds", "http://www.onvif.org/ver10/device/wsdl", NULL, NULL},
        {"tev", "http://www.onvif.org/ver10/events/wsdl", NULL, NULL},
        {"wsnt", "http://docs.oasis-open.org/wsn/b-2", NULL, NULL},
        {"timg", "http://www.onvif.org/ver20/imaging/wsdl", NULL, NULL},
        {"tmd", "http://www.onvif.org/ver10/deviceIO/wsdl", NULL, NULL},
        {"tptz", "http://www.onvif.org/ver20/ptz/wsdl", NULL, NULL},
        {"trt", "http://www.onvif.org/ver10/media/wsdl", NULL, NULL},
        {"tse", "http://www.onvif.org/ver10/search/wsdl", NULL, NULL},
        {NULL, NULL, NULL, NULL}
    };
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值