Libcurl使用OpenSSL编译出现undefined reference to `COMP_CTX_free'错误备忘

来源:互联网 发布:阿里云个人邮箱登录 编辑:程序博客网 时间:2024/06/05 19:24

2014-04-22 wcdj


在上篇文章中《Libcurl库支持SSL协议的编译方法》完成了对Libcurl库(支持SSL/TSL)的编译。然后用此库在编译demo时发现了如下编译错误:

$make -f demo_makefile g++  -o http_demo http_demo.o -L../../lib/ -L../../dep/curl-7.34.0/lib -L../../dep/openssl-1.0.1g/lib -lhttp -lcurl -lcrypto -lssl -lrt -lz -ldl../../dep/openssl-1.0.1g/lib/libssl.a(s3_clnt.o): In function `ssl3_check_cert_and_algorithm':s3_clnt.c:(.text+0x313): undefined reference to `X509_certificate_type'../../dep/openssl-1.0.1g/lib/libssl.a(s3_enc.o): In function `ssl3_change_cipher_state':s3_enc.c:(.text+0xc30): undefined reference to `COMP_CTX_free's3_enc.c:(.text+0xc4d): undefined reference to `COMP_CTX_new's3_enc.c:(.text+0xced): undefined reference to `COMP_CTX_free's3_enc.c:(.text+0xd06): undefined reference to `COMP_CTX_new'

网上这篇文章给出了解决方法,但是并没有给出原因,其实就是库的依赖问题(ssl依赖crypt的方法),仔细看OpenSSL的配置文件已经给出了正确的使用的方法。

I have solved the problem. The solution is simple, for some reason, when linking the library, -lssl must be in front of -lcrypto. This does not happen with the libraries provided by Ubuntu. I wonder why.... If anyone can shed some light on this, I would greatly appreciate it. But anyway, I solved the main issue. Hope this helps others like me.


Demo和Makefile可以参考GitHub上的代码。

https://github.com/gerryyang/wcdj/tree/master/src/demo/http



0 0
原创粉丝点击