【发布时间】:2020-11-28 05:26:51
【问题描述】:
我在 Windows 10 Professional 上使用 MinGW。
我使用以下命令安装了 libcurl:
$ git clone https://github.com/curl/curl
$ cd curl
$ ./buildconf.bat
$ mingw32-make mingw32
$ cp lib/libcurl.a /c/MinGW/lib
$ cp -r include/curl/ /c/MinGW/include
然后我编写了以下玩具 C++ 程序来测试它:
#include <iostream>
#include <curl/curl.h>
int main(void) {
CURL *curl;
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_URL, "https://api.ecs.rocks/v0/util/removeMessageHeader");
curl_easy_perform(curl);
curl_free(curl);
return 0;
}
然后我用以下命令编译它:
$ g++ main.cpp -o curltest -m32 -DCURL_STATICLIB -lcurl -lws2_32 -lwldap32 -lwsock32 -lwinmm
此时一切看起来都很好。我的密码现在包含一个名为 curltest.exe 的新文件。
我尝试运行它:
$ ./curltest.exe
我得到这个输出:
* Protocol "https" not supported or disabled in libcurl
* Closing connection -1
我做错了什么?如何在 MinGW 上从源代码构建的 libcurl 中启用对 HTTPS 的支持?
【问题讨论】:
-
运行
pkg-config --libs --flags curl会得到什么?? -
bash: pkg-config: command not found -
安装 pkg-config 并运行
pkg-config --libs --cflags curl后,我得到了Package curl was not found in the pkg-config search path。 -
首先您使用的是哪个编译器?在我看来,您正在使用 g++,只要设置了环境路径,GNU 就已经带有
pkg-cofig。我不知道单独安装它时会发生什么,但我相信它应该能够检测到已安装的 C++ 包。由于 curl 不在搜索路径中,因此您应该将其包含在 path 中的搜索路径中。可能您使用的是libcurl的变体。抱歉,我无法说出这里的问题是什么
标签: c++ gcc https mingw libcurl