Hi All, 

I am trying to run a Haskell program compiled on my Ubuntu box on a server box that does not have GHC installed and where I dont have root privileges. I run into several missing libraries, in particular libgmp, libffi and libuuid (the later two are needed by my program). How I can statically link my program such that I can run it on this server?

I have a tried static linking as follows:
  ghc -static -optl-static -optl-pthread --make -o p main.hs

This gives me several warnings of the form:
/usr/lib/haskell-packages/ghc6/lib/network-2.2.1.7/ghc-6.12.3/libHSnetwork-2.2.1.7.a(BSD.o): In function `sw4B_info':
(.text+0x584c): warning: Using 'getservbyport' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

And sure enough the generated executable segfaults on the server which has a different glibc version. 

Is there some way to static link all the other libraries needed except glibc? I have looked around for an example of this but to no avail and the output of the -v switch seemed a bit overwhelming. Or is there some other way to go about doing this?

thanks in advance,
Roshan

ps. including these, in case they maybe of some use: 

My machine:

$ ldd p
linux-vdso.so.1 =>  (0x00007fff3ffff000)
libncurses.so.5 => /lib/libncurses.so.5 (0x00007fbdbbf4f000)
libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007fbdbbd4a000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fbdbbb41000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007fbdbb93e000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fbdbb73a000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fbdbb51b000)
libgmp.so.3 => /usr/lib/libgmp.so.3 (0x00007fbdbb2be000)
libffi.so.5 => /usr/lib/libffi.so.5 (0x00007fbdbb0b6000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fbdbae30000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fbdbaa9c000)
/lib64/ld-linux-x86-64.so.2 (0x00007fbdbc1b5000)

Server:

$ ldd p
./p: /lib64/libuuid.so.1: no version information available (required by ./p)
        linux-vdso.so.1 =>  (0x00007fffc51fd000)
        libncurses.so.5 => /usr/lib64/libncurses.so.5 (0x00000037bce00000)
        libuuid.so.1 => /lib64/libuuid.so.1 (0x00000037b7200000)
        librt.so.1 => /lib64/librt.so.1 (0x00000037b5a00000)
        libutil.so.1 => /lib64/libutil.so.1 (0x00000037bda00000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00000037b4a00000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00000037b5200000)
        libgmp.so.3 => not found
        libffi.so.5 => not found
        libm.so.6 => /lib64/libm.so.6 (0x00000037b4e00000)
        libc.so.6 => /lib64/libc.so.6 (0x00000037b4600000)
        /lib64/ld-linux-x86-64.so.2 (0x00000037b4200000)