cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: gcc compile problem under ubuntu

From: Ben Noordhuis <info_at_bnoordhuis.nl>
Date: Wed, 20 Jun 2012 17:55:09 +0200

On Wed, Jun 20, 2012 at 5:49 PM, Alexandre BM <salexandre.bm_at_gmail.com> wrote:
> Hello everybody,
>
> I'm trying to compile a c programe that uses libcurl under Ubuntu 12.04,
> Libcurl is correctly installed (I hope). but the linking is not working
>
> gcc -lcurl functions.o main.o -o myprogram
>
> I'm gettings these errors :
>
> functions.c:(.text+0x5): undefined reference to `curl_easy_init'
> functions.c:(.text+0x23): undefined reference to `curl_easy_setopt'
> functions.c:(.text+0x2b): undefined reference to `curl_easy_perform'
> functions.c:(.text+0x38): undefined reference to `curl_easy_cleanup'
>
> Does anyone have an idea how can i fix it ?

gcc on ubuntu 12.04 links with -Wl,--as-needed. You likely need to
pass -lcurl as the last argument, e.g.:

  $ gcc functions.o main.o -o myprogram -lcurl
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-06-20