[Haskell-cafe] Re: static linking

Peter Gammie peteg42 at gmail.com
Wed May 28 05:03:10 EDT 2008


Hello,

Further on my static linking woes:

debian ~$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.8.2
-debian ~$ cat T.hs
main :: IO ()
main = putStrLn "Hello world"
-debian ~$ ghc -optl-static -static --make T.hs
Linking T ...
/usr/lib/gcc/i486-linux-gnu/4.2.3/../../../../lib/ 
librt.a(timer_create.o): In function `timer_create':
(.text+0x107): undefined reference to `pthread_once'
...
< references to missing pthread symbols >

Does anyone have static linking working for GHC 6.8.2 and can inform  
me of the magic incantation? "Get the latest development version from  
darcs", perhaps?

BTW when I said "move to the end", I meant "move to the end of -l  
flags".

cheers
peter

On 27/05/2008, at 10:37 AM, Peter Gammie wrote:

> Hello,
>
> I am having a bit of trouble static linking my program using GHC  
> 6.8.2.
>
> In brief: "rt" uses "pthread", but -lrt is the final thing on the  
> command line passed to the linker, and so the pthread symbols are  
> not resolved. Manually moving -lpthread to the end of the collect2  
> command line does the trick.
>
> The question is how to do this using ghc.
>
> This is on Debian, using the 6.8.2-5 from unstable.
>
> I can provide the command lines if that is helpful.
>
> Note the same setup worked fine under GHC 6.6.1.
>
> cheers
> peter



More information about the Haskell-Cafe mailing list