Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the proper way of using libcURL without the dlls?

Tags:

c++

libcurl

recently managed to use a libcurl in a test program for downloading a files. The code is this:

  CURL * curl;
  FILE * fout;
  CURLcode result;
  char * url = "http://blablabla.com/blablabla.txt";
  char filename[FILENAME_MAX] = "blablabla.txt";
  curl = curl_easy_init();
  if (curl)
  {
    fout = fopen(filename,"wb");
    curl_easy_setopt(curl, CURLOPT_URL, url);
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, fout);
    result = curl_easy_perform(curl);
    curl_easy_cleanup(curl);
    fclose(fout);
  }

and those things for directives:

#define CURL_STATICLIB
#include <curl/curl.h>

My question is how to make that I don't need to copy all of its dlls in the same dir with the exec to make it work:

libcurl.dll
libeay32.dll
libidn-11.dll
librtmp.dll
libssh2.dll
libssl32.dll
zlib1.dll

Cannot find info about that in the homesite (http://curl.haxx.se) of the library :|

like image 858
1000Gbps Avatar asked Mar 05 '12 10:03

1000Gbps


1 Answers

You mean, "how do I statically link libcurl"?

5.7 in the FAQ says:

When building an application that uses the static libcurl library, you must add -DCURL_STATICLIB to your CFLAGS. Otherwise the linker will look for dynamic import symbols. If you're using Visual Studio, you need to instead add CURL_STATICLIB in the "Preprocessor Definitions" section.

like image 142
Lightness Races in Orbit Avatar answered Oct 03 '22 20:10

Lightness Races in Orbit