libcurl编译---支持https

本文详细介绍了在编译curl时遇到SSL支持未启用的问题及其解决方案。通过正确配置openssl库路径并确保动态库被正确链接,最终实现curl对SSL的支持。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、先编译openssl(要生成动态库,以shared方式编译),然后执行make install 安装好

2、编译curl
添加 --with-ssl=XXX(openssl库安装的目录)
执行完./configure … 之后SSL support项后边应该是“enabled (OpenSSL)”如图:
在这里插入图片描述
如果是“no”,则是没有将openssl的动态库(.so)放到相应的lib目录下

出现问题解决:
1、编译curl的时候报错:

make[2]: Entering directory '/opt/scl/curl7.50.1/src'
  CCLD     curl
../lib/.libs/libcurl.so: undefined reference to `SSL_CTX_use_certificate_key_sm2enc'
../lib/.libs/libcurl.so: undefined reference to `GMT_VERSION_client_method'
../lib/.libs/libcurl.so: undefined reference to `SSLv2_client_method'
../lib/.libs/libcurl.so: undefined reference to `SSL_CTX_use_certificate_key_file_sm2enc'
collect2: error: ld returned 1 exit status
Makefile:771: recipe for target 'curl' failed
make[2]: *** [curl] Error 1
make[2]: Leaving directory '/opt/scl/curl7.50.1/src'
Makefile:649: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/opt/scl/curl7.50.1/src'
Makefile:883: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1

编译的时候没有链接openssl的库,看看是哪个目录下出错,上边的是src目录下的文件编译的时候出错了,所以需要打开src目录下的Makefile文件,可能里边有“-lssl…”这个参数,但是明显是没有用到,所以需要我们将其添加到CFLAS参数后边,这个参数是肯定用到了。

搞定,完工,再编译就没有问题了,可以使用了。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值