[Haskell-cafe] Static linking

Michael Oswald michael.oswald at siemens.com
Fri Jul 24 05:41:41 EDT 2009


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#Deployin
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+0xf1):

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?


lg,
Michael





More information about the Haskell-Cafe mailing list