如何解决 Borland c++ 中的 libCurl 链接器错误(5.02 版)?

发布于 2024-11-19 07:50:22 字数 596 浏览 4 评论 0原文

我是 c/c++ 新手......最近我尝试使用 libCurl 编译程序。但它向我显示了这些错误:

Error:  Error: Unresolved external '_curl_easy_init' referenced from D:\BC5\BIN\HTTP-POST.OBJ
Error:  Error: Unresolved external '_curl_easy_setopt' referenced from D:\BC5\BIN\HTTP-POST.OBJ
Error:  Error: Unresolved external '_curl_easy_perform' referenced from D:\BC5\BIN\HTTP-POST.OBJ
Error:  Error: Unresolved external '_curl_easy_cleanup' referenced from D:\BC5\BIN\HTTP-POST.OBJ

我在网上搜索了这些错误,并发现这是链接器错误。我找到了很多关于这个问题的教程。但我无法理解这一点。

请注意,我有 libcurl.dll 和很多头文件,我已将头文件复制到 D:\BC5\INCLUDE... 现在我该怎么办?

I am new in c/c++.... Recently I am trying to compile a program using libCurl. But it shows me these errors:

Error:  Error: Unresolved external '_curl_easy_init' referenced from D:\BC5\BIN\HTTP-POST.OBJ
Error:  Error: Unresolved external '_curl_easy_setopt' referenced from D:\BC5\BIN\HTTP-POST.OBJ
Error:  Error: Unresolved external '_curl_easy_perform' referenced from D:\BC5\BIN\HTTP-POST.OBJ
Error:  Error: Unresolved external '_curl_easy_cleanup' referenced from D:\BC5\BIN\HTTP-POST.OBJ

I have searched on net about these errors and came to know that this is linker error. I found many tutorials about that prob. But I can not understand that.

Note that I have libcurl.dll and lots of header file , I have copied header files in D:\BC5\INCLUDE....
Now what should I do?

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

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

发布评论

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

评论(2

月依秋水 2024-11-26 07:50:22

您的 DLL 需要一个导入库。您可以使用 borland 提供的 implib 实用程序从 DLL 创建一个。将生成的 .lib 包含在您的项目中,链接器错误应该会消失。如果它在运行时开始抱怨,请确保 DLL 与可执行文件位于同一文件夹中。

You need an import library for your DLL. You can use the implib utility provided by borland to create one from the DLL. Include the resulting .lib in your project and the linker errors should go away. If it start complaining at runtime make sure the DLL is in the same folders as your executable.

不弃不离 2024-11-26 07:50:22

Eelke 是正确的,您需要导入 libcurl 库才能正确解决这些错误。根据您到目前为止的评论,我假设您已经完成了以下操作:

  • 您在 ide 中拥有了 libcurl 测试项目设置的基本布局。
  • 添加了必要的 include 和 lib 目录,以便在构建时可以正确定位 libcurl。
  • 您已正确创建 libcurl.lib 导入文件以供链接器使用。

您可以通过两种方式链接所需的库:

  1. 使用工具链特定的#pragma指令。例如,在一个源文件的顶部附近添加:

     // 例如。主程序
     #include ;
     #include ;
    
     #pragma comment(lib, "libcurl.lib")
    
     // ...
    

  2. 将 libcurl 导入库添加到项目中。您可以通过右键单击项目名称->添加节点来完成此操作。在“添加到项目列表”窗口中,更改文件扩展名过滤器以查找 .lib。默认情况下,它以C++ 源代码开头。找到您之前导入的 libcurl.lib,然后单击“打开”。这会将导入库作为依赖项添加到项目中。

现在执行项目的重建(右键单击项目->构建节点),它应该可以工作。

Eelke is correct that you need to import the libcurl library to properly resolve those errors. Based on your comments above so far, I'm going to assume you've already done the following:

  • You have the basic layout of the libcurl test project setup in the ide.
  • Added the necessary include and lib directories so libcurl can be properly located when building.
  • You've properly created the libcurl.lib import file for use with the linker.

There are two ways you can link in the desired libraries:

  1. Use the tool-chain specific #pragma directive. For example, near the top of one of your source files add:

     // eg. main.cpp
     #include <stdio.h>
     #include <curl/curl.h>
    
     #pragma comment(lib, "libcurl.lib")
    
     // ...
    

    or

  2. Add the libcurl import library to the project. You can do this by right-clicking on the project name->add node. In the 'Add to Project List' window change the file extension filter to look for .lib. By default it starts with C++ source. Locate your libcurl.lib you imported earlier and click open. This will add the import library to the project as a dependency.

Now perform a rebuild of your project (right-click project->build node) and it should work.

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