如何解决 Borland c++ 中的 libCurl 链接器错误(5.02 版)?
我是 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的 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.
Eelke 是正确的,您需要导入 libcurl 库才能正确解决这些错误。根据您到目前为止的评论,我假设您已经完成了以下操作:
您可以通过两种方式链接所需的库:
使用工具链特定的
#pragma
指令。例如,在一个源文件的顶部附近添加:或
将 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:
There are two ways you can link in the desired libraries:
Use the tool-chain specific
#pragma
directive. For example, near the top of one of your source files add:or
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.