Compiling libcurl for https
Date: Wed, 21 Oct 2015 12:08:40 +1100
First post and a novice developer although I have spent the best part of
25 years hacking at various languages.
I'm using VS Community 2015 as an IDE.
I'm trying to evaluate libcurl as a library for use in another desktop
I managed to get some example code working after compiling libcurl. I
got all those symbol errors if I just tried to use the pre-compiled
The application even worked for HTTP source images.
When I tried it with the target URL with HTTPS it failed.
I did a curl.exe -V and https isn't listed as a supported source
although I'm not sure it supposed to. In some systems http implies https.
So my code works for HTTP but here it is just to make sure.
My question is do I need to do anything special to get libcurl to
support https or is there something else in the code that's missing?
size_t callbackfunction(void *ptr, size_t size, size_t nmemb, void*
FILE* stream = (FILE*)userdata;
printf("!!! No stream\n");
size_t written = fwrite((FILE*)ptr, size, nmemb, stream);
bool download_jpeg(char* url)
FILE* fp = fopen("out.jpg", "wb");
printf("!!! Failed to create file on the disk\n");
CURL* curlCtx = curl_easy_init();
curl_easy_setopt(curlCtx, CURLOPT_URL, url);
curl_easy_setopt(curlCtx, CURLOPT_WRITEDATA, fp);
curl_easy_setopt(curlCtx, CURLOPT_WRITEFUNCTION, callbackfunction);
curl_easy_setopt(curlCtx, CURLOPT_FOLLOWLOCATION, 1);
CURLcode rc = curl_easy_perform(curlCtx);
printf("!!! Failed to download: %s\n", url);
long res_code = 0;
curl_easy_getinfo(curlCtx, CURLINFO_RESPONSE_CODE, &res_code);
if (!((res_code == 200 || res_code == 201) && rc !=
printf("!!! Response code: %d\n", res_code);
int main(int argc, char** argv)
if (argc < 2)
printf("Usage: %s <url>\n", argv);
printf("!! Failed to download file: %s\n", argv);
List admin: http://cool.haxx.se/list/listinfo/curl-library
Received on 2015-10-21