libcurl - the multiprotocol file transfer library
libcurl is a free and easy-to-use client-side URL transfer library, supporting FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, LDAP, LDAPS, FILE, IMAP, SMTP, POP3 and RTSP. libcurl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, Kerberos4), file transfer resume, http proxy tunneling and more!
libcurl is highly portable, it builds and works identically on numerous platforms, including Solaris, NetBSD, FreeBSD, OpenBSD, Darwin, HPUX, IRIX, AIX, Tru64, Linux, UnixWare, HURD, Windows, Amiga, OS/2, BeOs, Mac OS X, Ultrix, QNX, OpenVMS, RISC OS, Novell NetWare, DOS and more...
libcurl is free, thread-safe, IPv6 compatible, feature rich, well supported, fast, thoroughly documented and is already used by many known, big and successful companies and numerous applications.
Homepage: http://curl.haxx.se/libcurl/
First, download and install cURL library package.
Then, use the utility 'curl-config' to get the compile options need for cURL program
$ curl-config --cflags $ curl-config --libs
This is a simple program that retrieve a web page:
#include <stdio.h> #include <curl/curl.h> int main() { CURL *curl; CURLcode res; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "xjaphx.blogspot.com"); res = curl_easy_perform(curl); curl_easy_cleanup(curl); } return 0; }
Try to compile with this option:
$ gcc -o curl_simple curl_simple.c `curl-config --libs` $ ./curl_simple
The header is needed in program `#include
$ whereis curl $ whereis curl.h
Probably, it will be /usr/bin/curl /usr/include/curl
While compile, you need to specify the linking library, that's why I set option `curl-config --libs`.
If you run this command alone
$ curl-config --libs -lcurlThat's the result. Instead, you can compile like this
$ gcc -o curl_simple curl_simple.c -lcurl
Which gives the same result.