gpt4 book ai didi

c - 如何使用 GCC(在 Windows 上)正确包含 libcurl?

转载 作者:太空宇宙 更新时间:2023-11-03 23:49:30 25 4
gpt4 key购买 nike

每当我在我的程序中#include 时,我都会收到链接器错误。我已经从 haxx.se 下载了 libcurl,编译了 libcurl.dll,并在编译时将 -Icurl 添加到我的 GCC 选项(以及尝试使用 -L 将直接路径添加到 dll)。但是,我仍然收到以下错误:

undefined reference to `_imp__curl_easy_init'
undefined reference to `_imp__curl_easy_setopt'
undefined reference to `_imp__curl_easy_setopt'
undefined reference to `_imp__curl_easy_perform'
undefined reference to `_imp__curl_easy_strerror'
undefined reference to `_imp__curl_easy_cleanup'

我的编译命令包括:​​

-Icurl -L"F:/GCCnew/lib/libcurl.dll"

我做错了什么?我怀疑这很简单,但我无法解决,搜索没有给我一个不使用类似 Code::blocks 的解决方案。

最佳答案

My compile command includes this:

-Icurl -L"F:/GCCnew/lib/libcurl.dll"

如果你使用mingw gcc,那么:

  • 首先,-L 必须有文件夹名称,而不是库名称。
  • 其次,必须有“-l”选项。例如 -lcurl。
  • 第三,-Icurl 与您的链接器错误无关

因此构建命令可能如下所示:

gcc your-file.c -o executable_name -L"F:/GCCnew/lib" -lcurl

有用的链接:

关于c - 如何使用 GCC(在 Windows 上)正确包含 libcurl?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24028680/

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