ld.exe 找不到-lcurl

发布于 2024-10-16 10:26:47 字数 3993 浏览 2 评论 0原文

(我发现了一个与此类似的问题,但它已经有 2 年历史了。)

我正在 Visual C++ 2008 中开发一个 Windows 窗体应用程序,它使用 libCurl 的 FTP 功能。尽管我已将 lib 和 include 目录添加到包含和库搜索路径,将 libcurl_imp.lib 添加到其他依赖项,并将 CURL_STATICLIB 添加到预处理器定义,但在构建它时出现 14 个链接器错误。我检查了 cURL 常见问题解答并用 Google 搜索了一些错误,但我还没有找到解决方案。链接器错误如下:(

1>-------.obj : error LNK2031: unable to generate p/invoke for "extern "C" void __clrcall curl_easy_cleanup(void *)" (?curl_easy_cleanup@@$$J0YMXPAX@Z); calling convention missing in metadata
1>-------.obj : error LNK2031: unable to generate p/invoke for "extern "C" enum CURLcode __clrcall curl_easy_perform(void *)" (?curl_easy_perform@@$$J0YM?AW4CURLcode@@PAX@Z); calling convention missing in metadata
1>-------.obj : error LNK2031: unable to generate p/invoke for "extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" (?curl_easy_setopt@@$$J0YM?AW4CURLcode@@PAXW4CURLoption@@ZZ); calling convention missing in metadata
1>-------.obj : error LNK2031: unable to generate p/invoke for "extern "C" void * __clrcall curl_easy_init(void)" (?curl_easy_init@@$$J0YMPAXXZ); calling convention missing in metadata
1>-------.obj : error LNK2028: unresolved token (0A00000E) "extern "C" void __clrcall curl_easy_cleanup(void *)" (?curl_easy_cleanup@@$$J0YMXPAX@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)
1>-------.obj : error LNK2028: unresolved token (0A00000F) "extern "C" enum CURLcode __clrcall curl_easy_perform(void *)" (?curl_easy_perform@@$$J0YM?AW4CURLcode@@PAX@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)
1>-------.obj : error LNK2020: unresolved token (0A000010) "extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" (?curl_easy_setopt@@$$J0YM?AW4CURLcode@@PAXW4CURLoption@@ZZ)
1>-------.obj : error LNK2020: unresolved token (0A000011) "extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" (?curl_easy_setopt@@$$J0YM?AW4CURLcode@@PAXW4CURLoption@@ZZ)
1>-------.obj : error LNK2028: unresolved token (0A000012) "extern "C" void * __clrcall curl_easy_init(void)" (?curl_easy_init@@$$J0YMPAXXZ) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)
1>-------.obj : error LNK2019: unresolved external symbol "extern "C" void __clrcall curl_easy_cleanup(void *)" (?curl_easy_cleanup@@$$J0YMXPAX@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)
1>-------.obj : error LNK2019: unresolved external symbol "extern "C" enum CURLcode __clrcall curl_easy_perform(void *)" (?curl_easy_perform@@$$J0YM?AW4CURLcode@@PAX@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)
1>-------.obj : error LNK2001: unresolved external symbol "extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" (?curl_easy_setopt@@$$J0YM?AW4CURLcode@@PAXW4CURLoption@@ZZ)
1>-------.obj : error LNK2019: unresolved external symbol "extern "C" void * __clrcall curl_easy_init(void)" (?curl_easy_init@@$$J0YMPAXXZ) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)

我删除了项目名称。)

是什么原因导致的,如何防止它?谢谢 :)


更新

我已经切换到 Code::Blocks,现在它是一个本机 Win32 GUI 应用程序。我没有得到所有这些链接器错误,但我确实得到了一些东西:

ld.exe cannot find -lcurl.lib

我没有将 include 和 lib 目录添加到搜索目录,而是将它们放在我的项目目录中。我对这个错误感到困惑,因为库的名称是 libcurl.lib,而不是curl.lib。对发生的事情有什么想法吗?

编辑:对所有编辑感到抱歉,我只是想提一下,我将 libcurl.lib 添加到了链接库中。


更新

现在我已将 -lcurl 添加到“其他链接选项”框中,错误已更改为

ld.exe cannot find -lcurl

没有 .lib 部分。

(I spotted a question similar to this, but it was 2 years old.)

I'm developing a Windows Form Application in Visual C++ 2008, which uses the FTP feature of libCurl. Although I've added the lib and include directories to the include and library search paths, added libcurl_imp.lib to Additional Dependencies and added CURL_STATICLIB to the Preproccessor Definitions, I get 14 linker errors when I build it. I checked the cURL FAQ and Google'd some of the errors, but I've yet to find a solution. The linker errors are as follows:

1>-------.obj : error LNK2031: unable to generate p/invoke for "extern "C" void __clrcall curl_easy_cleanup(void *)" (?curl_easy_cleanup@@$J0YMXPAX@Z); calling convention missing in metadata
1>-------.obj : error LNK2031: unable to generate p/invoke for "extern "C" enum CURLcode __clrcall curl_easy_perform(void *)" (?curl_easy_perform@@$J0YM?AW4CURLcode@@PAX@Z); calling convention missing in metadata
1>-------.obj : error LNK2031: unable to generate p/invoke for "extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" (?curl_easy_setopt@@$J0YM?AW4CURLcode@@PAXW4CURLoption@@ZZ); calling convention missing in metadata
1>-------.obj : error LNK2031: unable to generate p/invoke for "extern "C" void * __clrcall curl_easy_init(void)" (?curl_easy_init@@$J0YMPAXXZ); calling convention missing in metadata
1>-------.obj : error LNK2028: unresolved token (0A00000E) "extern "C" void __clrcall curl_easy_cleanup(void *)" (?curl_easy_cleanup@@$J0YMXPAX@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$HYMHP$01AP$AAVString@System@@@Z)
1>-------.obj : error LNK2028: unresolved token (0A00000F) "extern "C" enum CURLcode __clrcall curl_easy_perform(void *)" (?curl_easy_perform@@$J0YM?AW4CURLcode@@PAX@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$HYMHP$01AP$AAVString@System@@@Z)
1>-------.obj : error LNK2020: unresolved token (0A000010) "extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" (?curl_easy_setopt@@$J0YM?AW4CURLcode@@PAXW4CURLoption@@ZZ)
1>-------.obj : error LNK2020: unresolved token (0A000011) "extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" (?curl_easy_setopt@@$J0YM?AW4CURLcode@@PAXW4CURLoption@@ZZ)
1>-------.obj : error LNK2028: unresolved token (0A000012) "extern "C" void * __clrcall curl_easy_init(void)" (?curl_easy_init@@$J0YMPAXXZ) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$HYMHP$01AP$AAVString@System@@@Z)
1>-------.obj : error LNK2019: unresolved external symbol "extern "C" void __clrcall curl_easy_cleanup(void *)" (?curl_easy_cleanup@@$J0YMXPAX@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$HYMHP$01AP$AAVString@System@@@Z)
1>-------.obj : error LNK2019: unresolved external symbol "extern "C" enum CURLcode __clrcall curl_easy_perform(void *)" (?curl_easy_perform@@$J0YM?AW4CURLcode@@PAX@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$HYMHP$01AP$AAVString@System@@@Z)
1>-------.obj : error LNK2001: unresolved external symbol "extern "C" enum CURLcode __clrcall curl_easy_setopt(void *,enum CURLoption,...)" (?curl_easy_setopt@@$J0YM?AW4CURLcode@@PAXW4CURLoption@@ZZ)
1>-------.obj : error LNK2019: unresolved external symbol "extern "C" void * __clrcall curl_easy_init(void)" (?curl_easy_init@@$J0YMPAXXZ) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$HYMHP$01AP$AAVString@System@@@Z)

(I blanked out the project name.)

What's causing this, how can I prevent it? Thanks :)


UPDATE

I've switched to Code::Blocks and now its a native Win32 GUI App. I don't get all those linker errors, but I do get something:

ld.exe cannot find -lcurl.lib

Instead of adding the include and lib directories to the search directories, I just put them in my project directory. I am confused by this error because the name of the lib is libcurl.lib, and not curl.lib. Any ideas on what has happened?

EDIT: sorry for all the edits, I just wanted to mention that I added libcurl.lib to the Link Libraries.


UPDATE

Now I've added -lcurl to the Other Link Options box, the error has changed to

ld.exe cannot find -lcurl

without the .lib part.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凯凯我们等你回来 2024-10-23 10:26:47

确保库位于编译器的库搜索路径中,并且该库是针对与可执行文件相同的体系结构进行编译的(32 位与 64 位、单线程与多线程)。

Make sure the libs are in the library search path of the compiler and that the library is compiled for the same architecture as your executable (32 vs 64 bit, single vs multi threaded).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文