cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Statically linking in OS X

From: Toby Peterson <toby_at_apple.com>
Date: Sat, 22 Jan 2005 18:38:45 -0500

On 22 Jan 2005, at 14.30, Tomas Franzén wrote:

> I am building a .bundle on Mac OS X that uses libcurl.
> I want to make the bundle independent of installed libraries, so I
> want to link libcurl statically with my bundle.
> How do I accomplish this? I have tried running ./configure with
> --enable-static, but it still uses sqlite as a dynamically linked lib,
> and the resulting bundle is only 24 KB.
> --disable-shared doesn't improve things, either.
>
> I'm using Mac OS X 10.3.7 with XCode 1.2 and libcurl 7.12.3 on an iMac
> G5 1.8 GHz.

Nothing special, really. I wrote a simple curl client named test.c. Of
course, you could also statically link openssl and zlib in a similar
fashion.

== curl with ssl ==

% gcc -lz -lcrypto /usr/lib/libcurl.a test.c
% otool -L a.out
a.out:
         /usr/lib/libz.1.dylib (compatibility version 1.0.0, current
version 1.0.0)
         /usr/lib/libcrypto.0.9.7.dylib (compatibility version 0.9.7,
current version 0.9.7)
         /usr/lib/libSystem.B.dylib (compatibility version 1.0.0,
current version 71.1.1)

== curl without ssl (installed via DarwinPorts) ==

% gcc -lz /opt/local/lib/libcurl.a ctest.c
% otool -L a.out
a.out:
         /usr/lib/libz.1.dylib (compatibility version 1.0.0, current
version 1.0.0)
         /usr/lib/libSystem.B.dylib (compatibility version 1.0.0,
current version 71.1.1)

Regards,

- Toby
Received on 2005-01-23