I got a snippet off the web of how to download a file from online in c++ console with the curl library. so I installed curl, and copied the code snippet, but it doesnt work. Can someone show me whats wrong?
#include <curl/curl.h>
#include <cstdio>
// link with libcurl. eg.
// g++ -Wall -std=c++98 -pedantic -Werror -lcurl -I /usr/local/include -L /usr/local/lib
void get_page( const char* url, const char* file_name )
{
CURL* easyhandle = curl_easy_init() ;
curl_easy_setopt( easyhandle, CURLOPT_URL, url ) ;
std::FILE* file = std::fopen( file_name, "w" ) ;
curl_easy_setopt( easyhandle, CURLOPT_WRITEDATA, file ) ;
curl_easy_perform( easyhandle );
curl_easy_cleanup( easyhandle );
}
int main()
{
get_page( "www.research.att.com/~bs/",
"/tmp/stroustrup_home_page.html" ) ;
}
and heres the error:
[Linker error] undefined reference to `_imp__curl_easy_init'
[Linker error] undefined reference to `_imp__curl_easy_setopt'
[Linker error] undefined reference to `_imp__curl_easy_setopt'
[Linker error] undefined reference to `_imp__curl_easy_perform'
[Linker error] undefined reference to `_imp__curl_easy_cleanup'
ld returned 1 exit status
so does anyone know whats wrong? many thanks. :)