cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Can't compile my first libcurl app

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 16 Jan 2002 14:31:38 +0100 (MET)

On 15 Jan 2002, Matthew Nuzum wrote:

> I'm trying to compile my first curl app. Technically, it's not mine, I'm
> just using the sample "simple.c" to test the library.
>
> I'm not a c developer, (but I did have to learn it a while back) so I'm
> at a disadvantage in troubleshooting this.
>
> I have downloaded the curl-ssl-7.9.2-1.src.rpm and built the binary
> rpms. I then installed both the curl-ssl-7.9.2-1.i386.rpm and the
> curl-ssl-devel-7.9.2-1.i386.rpm files. ( I rebuilt them due to
> different openssl versions) Install went fine.
>
> Typing gcc simple.c presents me with the following messages:
> /tmp/cc4ETz4n.o: In function `main':
> /tmp/cc4ETz4n.o(.text+0x21): undefined reference to `curl_easy_init'
> /tmp/cc4ETz4n.o(.text+0x41): undefined reference to `curl_easy_setopt'
> /tmp/cc4ETz4n.o(.text+0x57): undefined reference to `curl_easy_setopt'
> /tmp/cc4ETz4n.o(.text+0x65): undefined reference to `curl_easy_perform'
> /tmp/cc4ETz4n.o(.text+0x78): undefined reference to `curl_easy_cleanup'
> collect2: ld returned 1 exit status
>
> I was able to confirm that all of the samples produce similar problems
> (except for gtk which is missing gtk stuff...).
>
> Should I try a different curl rpm, is it my gcc or do you think it's
> something else?

I think this is just a case of the linking using the command line options is
a slightly bad order.

What happens if you compile and link simple.c like this:

    $ gcc `curl-config --cflags` -c simple.c

    $ gcc -o simple simple.o `curl-config --libs`

These command lines of course require that you have installed (lib)curl prior
to this with 'make install'.

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
Received on 2002-01-16