Friday, December 16, 2011

How to use libcurl in C/C++

Newer languages such as Java and newer scripting languages such as Python come with good libraries to download files and do online work. A good way to download files using C/C++ is to download and install the libcurl library.
First run 'curl-config --libs' to see if you have the library '-libcurl'
search for the package: 'apt-cache search libcurl'
install the package: 'sudo apt-get install libcurl4-nss-dev'
check to see if you have the package again
Next, go to Copy and paste the code, save as 'simple.c' Change the "" to something you want.
Compile your code: 'gcc simple.c -lcurl -o simple.out'
Run the code: './simple.out'

Output of (