简体   繁体   中英

how to solve libCurl linker error in Borland c++ (version 5.02)?

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?

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 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM