gpt4 book ai didi

c++ - 无法使用 libcurl 库编译 C++ 程序

转载 作者:行者123 更新时间:2023-11-28 04:21:40 25 4
gpt4 key购买 nike

我正在使用编译器 MinGW64 和 Clion 开发人员。

我做了什么:

1) 从“https://curl.haxx.se/download.html”下载了 curl-7.64.0.tar.gz '

2) 通过cmd编译库-->curl-7.64.0 root-->'mingw32-make make'

3) 成功后,我将 header 放入我的 MinGW 的 include 文件夹中,将 libcurl.a 和 libcurldll.a 放入我的 MinGW 的 lib 文件夹中。

4) 然后我尝试在 Clion 中使用 CMake 设置简单的 libcurl 代码,如下所示:

cmake_minimum_required(VERSION 3.12)
add_executable(test main.cpp)
target_link_libraries(test libcurl.a libcurldll.a)

我的 main.cpp 代码是这样的:

#include <curl/curl.h>
#include <string>

int main()
{
auto curl = curl_easy_init();
}

当我编译它时,出现错误“进程已完成,退出代码为 -1073741515 (0xC0000135)”。

谁能告诉我哪里出了问题?

最佳答案

您必须将 -lcurl 放入 mingw 参数列表中。

你做过吗:

Make sure that MinGW32's bin dir is in the search path, for example:

set PATH=c:\mingw32\bin;%PATH%

then run mingw32-make mingw32 in the root dir. There are other make targets available to build libcurl with more features, use:

mingw32-make mingw32-zlib to build with Zlib support;
mingw32-make mingw32-ssl-zlib to build with SSL and Zlib enabled;
mingw32-make mingw32-ssh2-ssl-zlib to build with SSH2, SSL, Zlib;
mingw32-make mingw32-ssh2-ssl-sspi-zlib to build with SSH2, SSL, Zlib and SSPI support.

If you have any problems linking libraries or finding header files, be sure to verify that the provided "Makefile.m32" files use the proper paths, and adjust as necessary. It is also possible to override these paths with environment variables, for example:

set ZLIB_PATH=c:\zlib-1.2.8
set OPENSSL_PATH=c:\openssl-1.0.2c
set LIBSSH2_PATH=c:\libssh2-1.6.0

It is also possible to build with other LDAP SDKs than MS LDAP; currently it is possible to build with native Win32 OpenLDAP, or with the Novell CLDAP SDK. If you want to use these you need to set these vars:

set LDAP_SDK=c:\openldap
set USE_LDAP_OPENLDAP=1

or for using the Novell SDK:

set USE_LDAP_NOVELL=1

If you want to enable LDAPS support then set LDAPS=1

https://curl.haxx.se/docs/install.html

关于c++ - 无法使用 libcurl 库编译 C++ 程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55318871/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com