[Nix-dev] Compile Haskell program on nixos that works on ubuntu server

Cody Goodman codygman.consulting at gmail.com
Sat Jul 5 11:09:28 CEST 2014


Thanks Pascal.

I wish "-static" just worked Lluís:

[cody at cody-nixos:~/tmp]$ echo "main=undefined" > static-test.hs

[cody at cody-nixos:~/tmp]$ ghc -static static-test.hs
[1 of 1] Compiling Main             ( static-test.hs, static-test.o )
Linking static-test ...

[cody at cody-nixos:~/tmp]$ ldd static-test
    linux-vdso.so.1 (0x00007fff8f3fe000)
    libgmp.so.10 =>
/nix/store/wxkad81khi8gzxs8kppq5yqkki5hy0np-gmp-5.1.3/lib/libgmp.so.10
(0x00007f6f819d0000)
    libm.so.6 =>
/nix/store/pdskwizjw8ar31hql2wjnnx6g0s6xc50-glibc-2.19/lib/libm.so.6
(0x00007f6f816cf000)
    librt.so.1 =>
/nix/store/pdskwizjw8ar31hql2wjnnx6g0s6xc50-glibc-2.19/lib/librt.so.1
(0x00007f6f814c7000)
    libdl.so.2 =>
/nix/store/pdskwizjw8ar31hql2wjnnx6g0s6xc50-glibc-2.19/lib/libdl.so.2
(0x00007f6f812c3000)
    libgcc_s.so.1 =>
/nix/store/9fb027n5a2lf9qwpb98v77iycqq552pf-gcc-4.8.2/lib64/libgcc_s.so.1
(0x00007f6f810ad000)
    libc.so.6 =>
/nix/store/pdskwizjw8ar31hql2wjnnx6g0s6xc50-glibc-2.19/lib/libc.so.6
(0x00007f6f80d00000)
    libpthread.so.0 =>
/nix/store/pdskwizjw8ar31hql2wjnnx6g0s6xc50-glibc-2.19/lib/libpthread.so.0
(0x00007f6f80ae2000)
    /nix/store/pdskwizjw8ar31hql2wjnnx6g0s6xc50-glibc-2.19/lib/ld-linux-x86-64.so.2
(0x00007f6f81c53000)

On Sat, Jul 5, 2014 at 3:58 AM, Pascal Wittmann <PascalWittmann at gmx.net> wrote:
> On 07/05/2014 10:35 AM, Cody Goodman wrote:
>> I'm guessing I could use patchelf to change all of these manually? Is
>> there an easier way to statically link my binaries or am I doomed to
>> having to patchelf each field from now on myself?
>
> I have the same problem. My current solution is to use a script like
> ldd-copy [1] to copy all shared libraries into a single folder and use
> patchelf to refere to that folder.
>
>         ldd-copy homepage lib/
>         patchelf --set-rpath lib/ homepage
>         patchelf --set-interpreter lib/ld* homepage
>
> This is realy ugly, but works for me and I don't have time to
> investigate into a real solution.
>
> Hope this helps.
>
> [1] https://github.com/pSub/configs/blob/master/bin/ldd-copy
>
>
>
>
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>


More information about the nix-dev mailing list