Borland C++ 5.5.1, Uresolved External

C

chiefbutz

I am trying to compile an app that uses the libcurl API. I have the
files for that in the correct places. Then I compile I get the
following:
"Error: Unresolved ecternal '_curl_easy_init' refrenced from
c:\C++\CURL.OBJ
Error: Unresolved ecternal '_curl_easy_setopt' refrenced from
c:\C++\CURL.OBJ
Error: Unresolved ecternal '_curl_easy_perfrom' refrenced from
c:\C++\CURL.OBJ
Error: Unresolved ecternal '_curl_easy_cleanup' refrenced from
c:\C++\CURL.OBJ"

For now I am just testing to make sure I have the curl bit working, the
file stuff will come into use later, so here is my code:

"// basic file operations
#include <iostream>
#include <fstream>
#include <curl/curl.h>
using namespace std;

int main () {
// ofstream myfile;
// myfile.open ("example.txt");
// myfile << "Writing this to a file.\n";
// myfile.close();
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "google.com");
res = curl_easy_perform(curl);

/* always cleanup */
curl_easy_cleanup(curl);
cout << res;
}
return 0;
}"
 
D

Ducky Yazy

I am trying to compile an app that uses the libcurl API. I have the
files for that in the correct places. Then I compile I get the
following:
"Error: Unresolved ecternal '_curl_easy_init' refrenced from
c:\C++\CURL.OBJ
Error: Unresolved ecternal '_curl_easy_setopt' refrenced from
c:\C++\CURL.OBJ
Error: Unresolved ecternal '_curl_easy_perfrom' refrenced from
c:\C++\CURL.OBJ
Error: Unresolved ecternal '_curl_easy_cleanup' refrenced from
c:\C++\CURL.OBJ"

Have you link your app with the libcurl (libcurl.lib?) ?
 
D

Ducky Yazy

So you don't have any definitions of libcurl APIs? You have only the
"curl/curl.h" ?

Maybe you can find something more from your download website, e.g.
something like:
curl.cpp ????
 
E

Eric Jensen

I am trying to compile an app that uses the libcurl API. I have the
files for that in the correct places. Then I compile I get the
following:
"Error: Unresolved ecternal '_curl_easy_init' refrenced from

There are a few things that can be the trouble here.

libcurl ships as source code and is written in C.
Normally you would compile it yourself as a link library or
as a dynamic library. By default borland creates the .lib
file toghether with the dll when compiled.
In both cases you need to import the .lib file.

If you downloaded a already compiled libcurl as dll.
Then borland has a nice utility tool called implib.exe
It can create the import library by reading the dll.

e.g. implib libcurl.lib libcurl.dll

In case its a static library compiled with a non borland compiler
you can use the coff2omf.exe for converting .lib from coff format
into omf format (borland linker uses omf not coff)

If you added the libcurl C files into you cpp project and
compiles it all into 1 .exe. The .c files will be compiled as C
and .cpp files as c++. When accessing functions from the
compiled c files (.obj) from c++ you need to use extern statement
e.g.:

extern "C" {
#include "curl/curl.h"
}

//eric
 
T

The Last Ottoman

I faced this error before,
But it was because I called a function which I have not declared
before...

maybe it is just like that.
 
C

Chiefbutz

OK, I have the .lib file, now how do I use that in my program? (I am
newer to c++ incase you didn't guess)
 
E

Eric Jensen

Chiefbutz said:
OK, I have the .lib file, now how do I use that in my program? (I am
newer to c++ incase you didn't guess)

In borland c++ builder simply just add it to the project like any other file
and it will take care of the rest for you.

Project meny->add file to project

If you just use the command line tools the .lib file should be linked with
ilink32.exe

//eric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top