Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

curl: (2) Failed Initialization

Tags:

linux

curl

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.

like image 799
user3033152 Avatar asked Dec 02 '13 15:12

user3033152


1 Answers

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.

like image 94
Petesh Avatar answered Oct 22 '22 22:10

Petesh