I've found this thread while looking for a way to download a URL to my pc: Download file using libcurl in C/C++
I downloaded curl for windows and merged all 3 folders to their existing counterparts in the MinGW directory: include, lib, and bin.
Now, whenever I compile the code, I got the following errors that I know they are due to not linking the proper libraries, but in the link I provided their is no sufficient info on what to link:
obj\Debug\main.o
In function main':
D:\CPP Scrap\curl1\main.cpp:11: undefined reference to __imp__curl_easy_init'
D:\CPP Scrap\curl1\main.cpp:13: undefined reference to __imp__curl_easy_setopt'
D:\CPP Scrap\curl1\main.cpp:14: undefined reference to __imp__curl_easy_perform'
D:\CPP Scrap\curl1\main.cpp:17: undefined reference to __imp__curl_easy_cleanup'
=== Build finished: 4 errors, 0 warnings ===
It shows that the header curl/types.h is being included but I cannot find it in the [latest] version of curl I downloaded, so I'm guessing I have to link with something, question is, what is it?
Code:
#define CURL_STATICLIB 
#include <stdio.h> 
#include <curl/curl.h> 
#include <curl/types.h> 
#include <curl/easy.h> 
#include <string> 
size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) { 
    size_t written; 
    written = fwrite(ptr, size, nmemb, stream); 
    return written; 
} 
int main(void) { 
    CURL *curl; 
    FILE *fp; 
    CURLcode res; 
    char *url = "http://localhost/aaa.txt"; 
    char outfilename[FILENAME_MAX] = "C:\\bbb.txt"; 
    curl = curl_easy_init(); 
    if (curl) { 
        fp = fopen(outfilename,"wb"); 
        curl_easy_setopt(curl, CURLOPT_URL, url); 
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); 
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); 
        res = curl_easy_perform(curl); 
        curl_easy_cleanup(curl); 
        fclose(fp); 
    } 
    return 0; 
}
 
     
    