Do ghc-compiled binaries require GHC or are they self-contained?

后端 未结 4 1090
星月不相逢
星月不相逢 2020-12-05 03:44

If a friend wants to run my Haskell binaries, does he have to first install Haskell, or can he immediately run the binary by itself?

Is the answer the same on Mac, W

4条回答
  •  庸人自扰
    2020-12-05 04:35

    GHC compiles Haskell to object code, with a linked runtime. That means that you do not need a Haskell compiler installed to execute Haskell programs.

    The generated executable will use some variant of static and dynamic linking, for both C and Haskell library dependencies. Anything that is statically linked does not need to be installed on the user's machine. Anything that is dynamically linked must be installed.

    To see what you need to ship along with the executable, on Linux (or Cygwin), use ldd. You can force static linking of almost everything by passing -static to GHC.

提交回复
热议问题