<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.16.3">
</HEAD>
<BODY>
I did the following in my project and this is what I get:<BR>
<BR>
$&gt; runhaskell Setup configure --user --ghc-option=&quot;-optl -static&quot;<BR>
$&gt; runhaskell Setup build<BR>
...<BR>
...<BR>
/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.1/../../../../lib/librt.a(timer_create.o): In function `timer_create':<BR>
(.text+0x124): undefined reference to `pthread_once'<BR>
/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.1/../../../../lib/librt.a(timer_create.o): In function `timer_create':<BR>
(.text+0x171): undefined reference to `pthread_attr_init'<BR>
/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.1/../../../../lib/librt.a(timer_create.o): In function `timer_create':<BR>
(.text+0x1b8): undefined reference to `pthread_attr_setdetachstate'<BR>
/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.1/../../../../lib/librt.a(timer_routines.o): In function `__start_helper_thread':<BR>
(.text+0x3f): undefined reference to `pthread_attr_init'<BR>
/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.1/../../../../lib/librt.a(timer_routines.o): In function `__start_helper_thread':<BR>
(.text+0x4c): undefined reference to `pthread_attr_setstacksize'<BR>
/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.1/../../../../lib/librt.a(timer_routines.o): In function `__start_helper_thread':<BR>
(.text+0x92): undefined reference to `pthread_create'<BR>
/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.1/../../../../lib/librt.a(timer_routines.o): In function `__start_helper_thread':<BR>
(.text+0xc6): undefined reference to `pthread_attr_destroy'<BR>
/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.1/../../../../lib/librt.a(timer_routines.o): In function `__start_helper_thread':<BR>
(.text+0xd4): undefined reference to `pthread_atfork'<BR>
/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.1/../../../../lib/librt.a(timer_routines.o): In function `timer_helper_thread':<BR>
(.text+0x1e1): undefined reference to `pthread_exit'<BR>
/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.1/../../../../lib/librt.a(timer_routines.o): In function `timer_helper_thread':<BR>
(.text+0x21b): undefined reference to `pthread_create'<BR>
/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.1/libgcc_eh.a(unwind-dw2.o): In function `uw_init_context_1':<BR>
(.text+0x1b65): undefined reference to `pthread_once'<BR>
collect2: ld returned 1 exit status<BR>
<BR>
<BR>
Basically when GHC calls GCC it forgets to add -lpthread. By the way without --ghc-option=&quot;-optl -static&quot; everything works and it produces a nice dynamic binary.<BR>
<BR>
Regards<BR>
Nicola<BR>
<BR>
<BR>
<BR>
On Tue, 2008-08-12 at 13:21 -0700, Don Stewart wrote: 
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">tensor5:</FONT>
<FONT COLOR="#000000">&gt;    It seems that the -static flag serves a different purpose: according to</FONT>
<FONT COLOR="#000000">&gt;    the GHC manual it forces the compiler use the static Haskell libraries,</FONT>
<FONT COLOR="#000000">&gt;    but the resulting binary is still dynamically linked to the C libraries.</FONT>
<FONT COLOR="#000000">&gt;    What is the correct flag to create a static binary? Thanks</FONT>

<FONT COLOR="#000000">Pass -optl-static to GHC.</FONT>

<FONT COLOR="#000000">-- Don</FONT>
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>