Win32 - Generic curl-7.50.3.zip https://curl.haxx.se/download.html 解压 编译libcurl cd lib mingw32-make -f Makefile.m32 编译curl cd src mingw32-make -f Makefile.m32 复制 include\curl 到项目目录 复制 lib 目录下 libcurl.a libcurldll.a libcurl.dll 到项目 lib 目录下 修改Clion输出目录 Setting - Build - CMake,Build output path: bin 拷贝 libcurl.dll 到 bin/Debug 测试程序 #include#include "include/curl/curl.h" using namespace std; int main(int argc, char * argv[]) { CURL *curl; CURLcode res; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "https://www.xxx.com/"); //curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false); //curl_easy_setopt(curl, CURLOPT_PROXY, "10.59.77.11:8118"); res = curl_easy_perform(curl); if(CURLE_OK == res) { char *ct; /* ask for the content-type */ res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct); if((CURLE_OK == res) && ct) printf("We received Content-Type: %s\n", ct); } /* always cleanup */ curl_easy_cleanup(curl); } cout << endl; system("pause"); return 0; } 编译libcurl-7.50.3 with openssl-1.0.2j,use tdm-gcc-5.1.0-3 and git bash 2.9.0_x64 http://www.stringcat.com/company_blog/2015/12/07/compiling-openssl-on-windows-mingw32/ Requirements 1、perl http://www.activestate.com/activeperl perl -v 2、Mingw32 gcc -v 3、GNU make make -v 或 mingw32-make -v 4、tar tar --version Dynamic link libraries cd openssl-1.0.2j 1.perl Configure mingw shared it should do some stuff ( a minute or so) and should end with something like: Configured for mingw. 2. ./config -t ./config threads shared 复制 mingw32-make 为 make make depend make 或 mingw32-make 会生成 libcrypto.a libssl.a libssl.dll.a libcrypto.dll.a 这四个文件和相应的dll文件 把libssl.dll.a libcrypto.dll.a拷贝到out文件夹里,重命名为"libssl32.a" "libeay32.a" 再次把libssl.dll.a libcrypto.dll.a拷贝到out文件夹里,重命名为"libssl.a" "libcrypto.a" cd zlib-1.2.8 cp win32/makefile.gcc makefile.gcc mingw32-make -f makefile.gcc cd curl-7.50.3/lib 修改Makefile.m32 OPENSSL_PATH = ../../openssl-1.0.2j ZLIB_PATH = ../../zlib-1.2.8 mingw32-make -f Makefile.m32 SSL=1 ZLIB=1 cd curl-7.50.3/src 修改Makefile.m32 OPENSSL_PATH = ../../openssl-1.0.2j ZLIB_PATH = ../../zlib-1.2.8 mingw32-make -f Makefile.m32 SSL=1 ZLIB=1 MinGW使用-lxxx来链接库的时候,搜索库的顺序如下: libxxx.dll.a xxx.dll.a libxxx.a cygxxx.dll (*) libxxx.dll xxx.dll 把 curl-7.50.3\lib\libcurldll.a 拷贝到项目 lib 目录下并引入 把 openssl-1.0.2j 目录下 libeay32.dll ssleay32.dll 拷贝到项目输出目录下 把 zlib-1.2.8 目录下 zlib1.dll 拷贝到项目输出目录下