creating standalone executable with haskell

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

creating standalone executable with haskell

Damien Mattei-2
i want to run Haskell code on a system i'm not administrator???
if i compile my haskell program rather than use interpreter (i never compile it) can i run the executable on another Linux platform which has nothing of haskell installed on it ( no runtime library,etc...) ?
i already did that with Racket Scheme could it be done with GHC compiler or should i ask  the system admin to install haskell platform?
regards,
damien

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: creating standalone executable with haskell

Bram Neijt
For binaries there is the concept of a static binary that does not require any libraries. It is bound to the kernel ABI, but you could try that approach:


Good luck,

Bram

(Now also on the list)

On Tue, 5 Mar 2019, 11:42 Damien Mattei <[hidden email]> wrote:
i want to run Haskell code on a system i'm not administrator???
if i compile my haskell program rather than use interpreter (i never compile it) can i run the executable on another Linux platform which has nothing of haskell installed on it ( no runtime library,etc...) ?
i already did that with Racket Scheme could it be done with GHC compiler or should i ask  the system admin to install haskell platform?
regards,
damien
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: creating standalone executable with haskell

Niklas Hambüchen
In reply to this post by Damien Mattei-2
The two topics of creating standalone executables, and you not being a system admin, are very separate and don't have much to do with each other.

On the admin topic:
You can set up a full Haskell build environment in your home directory even if you are not an admin.

On the standalone executable topic:
Most Haskell compiled executables can easily run on other Linux systems.
In the default build, a Haskell executable has only a few runtime dependencies via dynamic linking. Here's and example for a HelloWorld program when compiled with `ghc --make`:

    % ldd Hello
        linux-vdso.so.1 =>  (0x00007ffcd9dea000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f3799dcd000)
        libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007f3799b4d000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f3799945000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f3799741000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f3799524000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f379915a000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f379a0d6000)

As you can see, a few C libraries must be present on the system.
They are already present on most systems.
Again, you don't need to be admin to get those; if they are missing, you can also ship them along with your executable and set LD_LIBRARY_PATH.

In general, executables created this way on one Linux flavour work reasonably well on other Linux flavours, but not always.
And example (if I remember correctly) where it doesn't work, is Centos 6 vs. newer Debian; one has libgmp.so.3 and one libgmp.so.6.
This means that if you are using the default dynamic linking of C dependencies, you may have to ship "a few" (usually two) flavours of your executable.
In general, executables created on one OS version work well on newer ones, e.g. something created on Ubuntu 16.04 will work well on newer Ubuntus.

You can also link everything statically.
Then your executable should work on any Linux system.
But you need to learn a few more things to do so; I try to make it as convenient as possible with my project
    https://github.com/nh2/static-haskell-nix/

Niklas
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: creating standalone executable with haskell

Damien Mattei-2
thank for all the advices,
i will keep all that in mind when it's time to update the DB on the server.
regards,
damin

On Tue, Mar 5, 2019 at 1:33 PM Niklas Hambüchen <[hidden email]> wrote:
The two topics of creating standalone executables, and you not being a system admin, are very separate and don't have much to do with each other.

On the admin topic:
You can set up a full Haskell build environment in your home directory even if you are not an admin.

On the standalone executable topic:
Most Haskell compiled executables can easily run on other Linux systems.
In the default build, a Haskell executable has only a few runtime dependencies via dynamic linking. Here's and example for a HelloWorld program when compiled with `ghc --make`:

    % ldd Hello
        linux-vdso.so.1 =>  (0x00007ffcd9dea000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f3799dcd000)
        libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007f3799b4d000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f3799945000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f3799741000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f3799524000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f379915a000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f379a0d6000)

As you can see, a few C libraries must be present on the system.
They are already present on most systems.
Again, you don't need to be admin to get those; if they are missing, you can also ship them along with your executable and set LD_LIBRARY_PATH.

In general, executables created this way on one Linux flavour work reasonably well on other Linux flavours, but not always.
And example (if I remember correctly) where it doesn't work, is Centos 6 vs. newer Debian; one has libgmp.so.3 and one libgmp.so.6.
This means that if you are using the default dynamic linking of C dependencies, you may have to ship "a few" (usually two) flavours of your executable.
In general, executables created on one OS version work well on newer ones, e.g. something created on Ubuntu 16.04 will work well on newer Ubuntus.

You can also link everything statically.
Then your executable should work on any Linux system.
But you need to learn a few more things to do so; I try to make it as convenient as possible with my project
    https://github.com/nh2/static-haskell-nix/

Niklas

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.