[Haskell-cafe] Static linking

Marcin Kosiba marcin.kosiba at gmail.com
Fri Jul 24 07:56:49 EDT 2009


On Friday 24 July 2009, Michael Oswald wrote:
> Hello,
>
>
> I wrote a small installer program which configures and installs some
> software packages. In order to be able to let it run on a different
> machine, where I possibly don't have the needed shared libraries, I tried
> to link it statically, following this advice:
>
> http://www.haskell.org/haskellwiki/Practical_web_programming_in_Haskell#Dep
>loyin g_statically_linked_applications
>
> However I get some linking errors:
>
>  ghc --make Installer.hs -static -optl-static
>
> /usr/lib/ghc-6.10.3/unix-2.3.2.0/libHSunix-2.3.2.0.a(User__143.o)(.text+0xf
>1):
>
> In function `s7Tu_info':
> : warning: Using 'getgrnam_r' in statically linked applications requires at
>
> runtime the shared libraries from the glibc version used for linking
> /usr/lib/gcc-lib/i586-suse-linux/3.3.3/../../../libedit.a(readline.o)(.text
>+0x7b 2):
>
> In function `username_completion_function':
> /home/oswald/build/libedit-20090610-3.0/src/readline.c:1467:0:
>      warning: Using 'getpwent' in statically linked applications requires
> at runtime the shared libraries from the glibc version used for linking
>
> src/dlmalloc.c:2486:0:  undefined reference to `pthread_mutex_lock'
> /usr/lib/ghc-6.10.3/libffi.a(closures.o)(.text+0x132):src/dlmalloc.c:2493:
> undefined reference to `pthread_mutex_unlock'
> /usr/lib/ghc-6.10.3/libffi.a(closures.o)(.text+0x184):src/dlmalloc.c:2490:
> undefined reference to `pthread_mutex_init'
> /usr/lib/ghc-6.10.3/libffi.a(closures.o)(.text+0x227): In function
> `ffi_closure_free':
>
>
> Because of the undefined references to pthread_mutex_lock I then
> tried various versions of
>
> ghc --make Installer.hs -static -optl-static -lpthread -lrt
>
> and reordered the -l switches, but neither combination helped. I always get
> the same error.
>
> Does somebody know how to correctly specify the pthread library for this?

Hi,
	Try:
	ghc --make Installer.hs -static -optl-static -optl-pthread

If that doesn't work, you can always do a ghc -v, find the command it uses for 
linking, modify it and run it manually.

Thanks!
	Marcin Kosiba
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090724/d14a33dd/attachment-0001.bin


More information about the Haskell-Cafe mailing list