【问题标题】:GCC on MinGW: Protocol "https" not supported or disabled in libcurlMinGW 上的 GCC:libcurl 中不支持或禁用协议“https”
【发布时间】: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


【解决方案1】:

您已经构建了没有任何 TLS 库的 libcurl。 我建议您查看official curl guide,了解如何在 MingW32 上构建 curl。它还解释了如何启用 TLS。

【讨论】:

    猜你喜欢
    • 2019-08-06
    • 2012-03-24
    • 2017-01-10
    • 2017-09-14
    • 2020-01-22
    • 2017-09-08
    • 2020-04-09
    • 2015-03-16
    • 2013-03-11
    相关资源
    最近更新 更多