Static linking for machines that don't have Haskell

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)* * *

Roshan James
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*
Yes, the Linux libc doesn't really support static linking, and in fact actively subverts it by dynamically loading other libraries from hardwired paths. I'm sure there's a good reason for it. Some things can be worked around by setting environment variables etc, but generally, try to compile on the oldest system you can find (since backwards compatibility is better supported than forward), and use the same distribution. Use strace to see what dynamic libraries your executable tries to load, and Google to see what can be done about them. The best solution would be to use a different libc. -k -- If I haven't seen further, it is by standing in the footprints of giants
participants (2)
-
Ketil Malde
-
Roshan James