Febin Sunny
Febin Sunny

Reputation: 311

Trying to use libcurl in my program and getting "undefined reference" errors

I am getting the following errors:

/tmp/ccno287V.o: In function `download_feed':

feedObtain.c:(.text+0xb9): undefined reference to `curl_easy_init'
feedObtain.c:(.text+0xde): undefined reference to `curl_easy_setopt'
feedObtain.c:(.text+0xff): undefined reference to `curl_easy_setopt'
feedObtain.c:(.text+0x10b): undefined reference to `curl_easy_perform'
collect2: error: ld returned 1 exit status

Command used to get libcurl:

apt-get install libcurl4-gnut

Upvotes: 1

Views: 239

Answers (1)

P.P
P.P

Reputation: 121427

Your program is not linked with the libcurl library and hence the linker complains that it could resolve symbols. Link the library with:

cc feedObtain.c -lcurl

Note that the library must be specified at the end of the commandline options.

Upvotes: 2

Related Questions