How to produce a statically linked binary with GHC?

Nicola Squartini tensor5 at gmail.com
Fri Aug 15 02:55:48 EDT 2008


It works! This is much easier, thank you

Nicola

On Thu, Aug 14, 2008 at 11:30 PM, Agent Zhang <agentzh at gmail.com> wrote:

> 2008/8/15 Nicola Squartini <tensor5 at gmail.com>
> >
> > So I run that gcc command manually adding -lpthread at the end of it end
> it works,
> >  I get the static binary. Isn't it strange? It could be a gcc problem.
>
> Well, it needn't be that hacky ;) The following command works for me
> and it does essentially the same thing:
>
>   ghc -i -static -optl-static -optl-pthread -funbox-strict-fields
> -fwarn-incomplete-patterns -isrc --make Main -o bin/restyscript
>
> Please note that without -optl-pthread option, I'll get exactly the same
> errors:
>
> Linking bin/restyscript ...
> /usr/lib/gcc/i486-linux-gnu/4.2.3/../../../../lib/librt.a(timer_create.o):
> In function `timer_create':
> (.text+0x117): undefined reference to `pthread_once'
> /usr/lib/gcc/i486-linux-gnu/4.2.3/../../../../lib/librt.a(timer_create.o):
> In function `timer_create':
> ...
>
> -lpthread needs to be put to the end of the argument list to help gcc
> or ld solve the symbols properly.
>
> Hope this helps ;)
>
> -agentzh
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20080814/36d59615/attachment-0001.htm


More information about the Glasgow-haskell-users mailing list