在没有dll的情况下使用libcURL的正确方法是什么?

100*_*bps 4 c++ libcurl

最近设法在测试程序中使用libcurl来下载文件.代码是这样的:

  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);
  }
Run Code Online (Sandbox Code Playgroud)

以及指令的那些东西:

#define CURL_STATICLIB
#include <curl/curl.h>
Run Code Online (Sandbox Code Playgroud)

我的问题是如何使我不需要在exec中将所有dll复制到同一目录中以使其工作:

libcurl.dll
libeay32.dll
libidn-11.dll
librtmp.dll
libssh2.dll
libssl32.dll
zlib1.dll
Run Code Online (Sandbox Code Playgroud)

无法在库的主页(http://curl.haxx.se)中找到有关该信息的信息:|

Lig*_*ica 11

你的意思是,"我如何静态链接libcurl"?

FAQ中的 5.7 说:

构建使用静态libcurl库的应用程序时,必须添加-DCURL_STATICLIB到您的CFLAGS.否则,链接器将查找动态导入符号.如果您使用的是Visual Studio,则需要添加CURL_STATICLIB"预处理程序定义"部分.