static linking with ghc?

Hi. I want to produce a statically linked executable. I am trying 'ghc --make -fforce-recomp -static -optl-static Main' but it gives lots of errors like (.text+0xfa): undefined reference to `pthread_mutex_unlock' collect2: ld returned 1 exit status A similar thing is mentioned here (see Caveat) http://www.haskell.org/haskellwiki/Web/Literature/Static_linking The ghc user guide talks a great length about shared libs http://www.haskell.org/ghc/docs/latest/html/users_guide/using-shared-libs.ht... but I don't see anything on how to switch this off. - J.W.

Adding -optl-pthread fixes it for me. On Sun, 22 Apr 2012, Johannes Waldmann wrote:
Hi.
I want to produce a statically linked executable. I am trying 'ghc --make -fforce-recomp -static -optl-static Main'
but it gives lots of errors like (.text+0xfa): undefined reference to `pthread_mutex_unlock' collect2: ld returned 1 exit status
A similar thing is mentioned here (see Caveat) http://www.haskell.org/haskellwiki/Web/Literature/Static_linking
The ghc user guide talks a great length about shared libs http://www.haskell.org/ghc/docs/latest/html/users_guide/using-shared-libs.ht... but I don't see anything on how to switch this off.
- J.W.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Scott Lawrence

On 22 April 2012 22:33, Johannes Waldmann
Hi.
I want to produce a statically linked executable. I am trying 'ghc --make -fforce-recomp -static -optl-static Main'
but it gives lots of errors like (.text+0xfa): undefined reference to `pthread_mutex_unlock' collect2: ld returned 1 exit status
I believe this is due to C libraries that are used in GHC's RTS; all Haskell libs are statically linked by default.
A similar thing is mentioned here (see Caveat) http://www.haskell.org/haskellwiki/Web/Literature/Static_linking
The ghc user guide talks a great length about shared libs http://www.haskell.org/ghc/docs/latest/html/users_guide/using-shared-libs.ht... but I don't see anything on how to switch this off.
- J.W.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com http://IvanMiljenovic.wordpress.com

Johannes Waldmann
A similar thing is mentioned here (see Caveat) http://www.haskell.org/haskellwiki/Web/Literature/Static_linking
Another caveat is that shared linking isn't very useful on Linux, since the C library loads various stuff dynamically anyway. It'd be great to be able to link to a different C library (maybe something from the BSDs?). -k -- If I haven't seen further, it is by standing in the footprints of giants
participants (4)
-
Ivan Lazar Miljenovic
-
Johannes Waldmann
-
Ketil Malde
-
Scott Lawrence