cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: gcc compile problem under ubuntu

From: Alexandre BM <salexandre.bm_at_gmail.com>
Date: Wed, 20 Jun 2012 17:04:17 +0100

On 20/06/2012 16:55, Ben Noordhuis wrote:
> 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

So this is specific to ubuntu ? cause it's correctly working under
Debian ! can you explain me why ?

PS : thank's it's working now !

> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-06-20