cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Can't compile my first libcurl app

From: Matthew Nuzum <newz_at_cyberdude.com>
Date: 16 Jan 2002 09:53:55 -0500

On Wed, 2002-01-16 at 08:31, Daniel Stenberg wrote:
    On 15 Jan 2002, Matthew Nuzum wrote:

> 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 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'.

It works, of course. I realize you're busy with other things, but could
you tell me what this does? I have never had to write a program that
uses any command line options for gcc. Most of my work is in Perl or
PHP.

I tested your instructions with g++ and they worked just fine as well.
Do you think there will be any other gotchas that may appear later due
to g++?

Thanks for your help,
Matt Nuzum
Received on 2002-01-16