curl:(2)初始化失败 [英] curl: (2) Failed Initialization

查看:118
本文介绍了curl:(2)初始化失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Linux上安装了libcurl 7.33.0.我使用以下命令进行安装:

./configure  
make  
make install

如果运行curl http://www.google.com,则会出现以下错误: 卷曲:(2)初始化失败

curl安装在/usr/local/bin中,头文件安装在/usr/local/include/curl中.

curl-config:

sandesh@ubuntu:~$ curl-config --features  
IPv6  
libz  
sandesh@ubuntu:~$ curl-config --protocols  
DICT  
FILE  
FTP  
GOPHER    
HTTP  
IMAP  
POP3  
RTSP  
SMTP  
TELNET  
TFTP  
sandesh@ubuntu:~$ curl-config --ca  
/etc/ssl/certs/ca-certificates.crt  
sandesh@ubuntu:~$ curl-config --cflags  
-I/usr/local/include  
sandesh@ubuntu:~$ curl-config --configure  

sandesh@ubuntu:~$ curl-config --libs  
-L/usr/local/lib -lcurl  
sandesh@ubuntu:~$ curl-config --static-libs  
/usr/local/lib/libcurl.a -lz -lrt  

我相信这与我的配置有关.

解决方案

一个疯狂的猜测是,您已经将/usr/local/bin/curl二进制文件链接到了系统curl库.

要验证是这种情况,您应该执行以下操作:

ldd /usr/local/bin/curl

如果它指示类似这样的行:

libcurl.so.4 => /usr/lib/x86_64-linux-gnu/libcurl.so.4 (0x00007fea7e889000)

这意味着curl二进制文件正在获取系统curl库.虽然它是在编译时链接到正确的库的,但在运行时却选择了不正确的库,这似乎是发生此错误的一个很典型的原因.

如果使用--disable-shared运行configure,则将生成一个.a,当链接到curl二进制文件时,它将不依赖于系统libcurl.so,而是具有其自己的私有代码. /p>

如果要交叉编译,那么还需要交叉编译所有依赖库,这是另一个问题.

I have installed libcurl 7.33.0 on Linux. I used the following commands to install:

./configure  
make  
make install

If I run curl http://www.google.com I get following error: curl: (2) Failed initialization

curl is installed at /usr/local/bin and header files at /usr/local/include/curl.

curl-config:

sandesh@ubuntu:~$ curl-config --features  
IPv6  
libz  
sandesh@ubuntu:~$ curl-config --protocols  
DICT  
FILE  
FTP  
GOPHER    
HTTP  
IMAP  
POP3  
RTSP  
SMTP  
TELNET  
TFTP  
sandesh@ubuntu:~$ curl-config --ca  
/etc/ssl/certs/ca-certificates.crt  
sandesh@ubuntu:~$ curl-config --cflags  
-I/usr/local/include  
sandesh@ubuntu:~$ curl-config --configure  

sandesh@ubuntu:~$ curl-config --libs  
-L/usr/local/lib -lcurl  
sandesh@ubuntu:~$ curl-config --static-libs  
/usr/local/lib/libcurl.a -lz -lrt  

I believe it is something to do with my configuration.

解决方案

At a wild guess, you've linked the /usr/local/bin/curl binary to the system curl library.

To verify that this is the case, you should do:

ldd /usr/local/bin/curl

If it indicates a line like:

libcurl.so.4 => /usr/lib/x86_64-linux-gnu/libcurl.so.4 (0x00007fea7e889000)

It means that the curl binary is picking up the system curl library. While it was linked at compile time to the correct library, at run-time it's picking up the incorrect library, which seems to be a pretty typical reason for this error happening.

If you run the configure with --disable-shared, then it will produce a .a, which, when linked to the curl binary will not depend on the system libcurl.so, but will instead have it's own private code.

If you're cross-compiling, then you'll also need to cross-compile all the dependent libraries, and that is another question.

这篇关于curl:(2)初始化失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆