cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Getting curl to work with g++ on Mac

From: m. allan noah <kitno455_at_gmail.com>
Date: Wed, 3 Jun 2009 15:26:45 -0400

On Wed, Jun 3, 2009 at 3:13 PM, Kushan Thakkar<kthakk4_at_gmail.com> wrote:
> I am trying to use curl with g++ compiler on mac. I am not an expert when I
> comes to compliers, but I have done the following from the information I
> have been able to find online:
>
> - installed CURL
> - here is the output of information I received with curl-config utility
> version:  libcurl 7.16.3
> prefix:     /usr
> cflags:    (NONE)
> libs:        -lcurl -lssl -lcrypto -lz
>
> when I compile my program from command line using # g++ -o App test.cpp
>
> I get the following error:
> Undefined symbols:
>   "_curl_easy_perform", referenced from:
>       _main in ccr07sIp.o
>   "_curl_easy_setopt", referenced from:
>       _main in ccr07sIp.o
>   "_curl_easy_cleanup", referenced from:
>       _main in ccr07sIp.o
>   "_curl_easy_init", referenced from:
>       _main in ccr07sIp.o
> ld: symbol(s) not found
> collect2: ld returned 1 exit status
>
> I understand that this means that I need to link libraries (-lcurl -lssl
> -lcrypto -lz) in order to take care of this error, however I was not able to
> find any information on how to do so:
>
> this is what I have tried so far:
>
> 1)  # g++ -L/usr/lib -lcurl -lssl -lcrypto -lz
>
> Error:
> Undefined symbols:
>   "_main", referenced from:
>       start in crt1.10.5.o
> ld: symbol(s) not found
> collect2: ld returned 1 exit status
>
> 2) g++ -L/usr/lib -lcurl -lssl -lcrypto -lz main.o
>
> Error:
> i686-apple-darwin9-g++-4.0.1: main.o: No such file or directory
>
> What should be my next step?
>
> Any help (including suggestions on other utilities that allows to get http
> files from c++) will be greatly appreciated.
>
>
>
>

combine your steps:

g++ -lcurl -lssl -lcrypto -lz -o App test.cpp

chances are you dont need -L/usr/lib, since that's a pretty standard
location for libs :)

allan

-- 
"The truth is an offense, but not a sin"
Received on 2009-06-03