cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: cURL tool static build

From: Ciprian Dorin, Craciun <ciprian.craciun_at_gmail.com>
Date: Wed, 2 Dec 2009 19:35:50 +0200

On Wed, Dec 2, 2009 at 10:00 AM, Ciprian Dorin, Craciun
<ciprian.craciun_at_gmail.com> wrote:
> On Wed, Dec 2, 2009 at 8:31 AM, Pletter Thomas <T.Pletter_at_rewe-group.at> wrote:
>> hello,
>>
>> I had also the same problem. I wanted to compile statically for HPUX and
>> it only works with Environment Variable
>> LD_LIBRARY_PATH. All options for "configure" have no influence for the
>> compilation. So we created a fix in script "configure" !
>> Then it works. If you want the fix, i can send it.
>>
>> regards,Tom
>>
>>
>> -----Original Message-----
>> From: curl-users-bounces_at_cool.haxx.se
>> [mailto:curl-users-bounces_at_cool.haxx.se] On Behalf Of Ciprian Dorin,
>> Craciun
>> Sent: Tuesday, December 01, 2009 6:29 PM
>> To: curl-users_at_cool.haxx.se
>> Subject: cURL tool static build
>>
>>    Hello all!
>>
>>    I know that this question has been made thousands of times on the
>> mailing list, but here goes again :)...
>>
>>    How do I make curl compile statically? (I mean the curl tool, not
>> another executable that uses libcurl).
>>
>>    I've tried the following combinations:
>> ~~~~
>> ./configure --disable-shared --enable-static
>> ~~~~
>> export LDFLAGS=-static
>> ./configure --disable-shared --enable-static
>> ~~~~
>> export LIBS=-static
>> ./configure --disable-shared --enable-static
>> ~~~~
>> export LDFLAGS=-static
>> export LIBS=-static
>> ./configure --disable-shared --enable-static
>> ~~~~
>> export CFLAGS=-static
>> export LDFLAGS=-static
>> export LIBS=-static
>> ./configure --disable-shared --enable-static
>> ~~~~
>>    (and some other combinations...)
>>
>>    Am I doing something wrong?
>>
>>    Thanks,
>>    Ciprian.
>
>
>    Please send me that patch! (And also on the list, maybe others are
> interested too.)
>
>    Thanks,
>    Ciprian.

    Thanks to Thomas's patch, I was able to convience cURL to
statically build without modifying the cURL source tree. All we have
to do is:
    ./configure CFLAGS='-static -static-libgcc -Wl,-static -lc'

    Why? I'm guessing:
    * `-static` is for the compiler;
    * and `-static-libgcc` is for forcing also GCC internal library to
be static; (why? because else it fails to find libgcc_s.a which only
exists in .so format;)
    * `-lc` is to solve the missing reference to dl_iterate_<something>;
    * `-Wl,-static` is to convince also the linker to output static
executables; (it seems that at link-time, LDFLAGS are completely
ignored by cURL make scripts;)

    (This worked on ArchLinux with gcc 4.4.0, and no other options to
`./configure`.)

    Hope it's going to be helpful for others too.
    Ciprian.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-12-02