7

Using libcurl to download files in Windows

view full story
linux-howto

http://www.daniweb.com – Hi! My problems are more of porting a code to Windows, than the code itself. I need to download a file from a URL (http://127.0.0.1/img.jpg) and store it in a local file. I think I've screwed up the setting up of the libcurl libraries. I am using Visual Studio 2008 as my IDE. I first downloaded the zipped file with the libraries. I downloaded the file from here: http://www.gknw.net/mirror/curl/win3...el-mingw32.zip The description on the libcurl site said: "This package is type libcurl This is a pure binary libcurl package, possibly including header files and documentation, but without the command line tool and other cruft. If you want libcurl for a program that uses libcurl, this is most likely the package you want." Which fits in to what I want to do. In my Visual Studio options, I added the libcurl folder in the 'include' path. I also added the bin folder (with all the .dll files) to my 'libraries' path. I ran the following code: #include <iostream> #include <curl/curl.h> #include <curl/types.h> #include <curl/easy.h> using namespace std; size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) {     size_t written = fwrite(ptr, size, nmemb, stream);     return written; } int downloader(string url) {     CURL *curl;     FILE *fp;     curl = curl_easy_init();     return 0; } However, when I build the code, I get the following linking error: Quote: error LNK2001: unresolved external symbol __imp__curl_easy_init fatal error LNK1120: 1 unresolved externals So, I next went and added all the dll's in the bin folder in the dependencies (Properties -> Linker -> Input-> Additional Dependencies). (I could not find .lib files anywhere.) Now when I compile it, I get the following error: [QUOTE\C:\Program Files\libcurl\bin\libcurl.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x2B8[/QUOTE] Any idea what's the problem? (General)