cURL / Mailing Lists / curl-library / Single Mail

curl-library

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

From: Kamil Dudka <kdudka_at_redhat.com>
Date: Wed, 3 Jun 2009 21:33:54 +0200

On Wednesday 03 of June 2009 21:13:23 Kushan Thakkar 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.

Try to put it together:
g++ -o App test.cpp -L/usr/lib -lcurl -lssl -lcrypto -lz

If you want it splitted in two steps:
g++ -c -o main.o test.cpp
g++ -L/usr/lib -lcurl -lssl -lcrypto -lz main.o

The output should be then a.out or you can specify a meaningful name with -o
here as well.

Kamil
Received on 2009-06-03