ghc 编译的二进制文件是否需要 GHC 或者它们是独立的? [英] Do ghc-compiled binaries require GHC or are they self-contained?

查看:17
本文介绍了ghc 编译的二进制文件是否需要 GHC 或者它们是独立的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果朋友想要运行我的 Haskell 二进制文件,他必须先安装 Haskell,还是可以立即自行运行二进制文件?

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?

在 Mac、Windows 和 Linux 上答案是否相同?

Is the answer the same on Mac, Windows, and Linux?

推荐答案

GHC 确实会生成不需要安装 GHC 本身的独立二进制文件,但是它们确实链接到一些动态库,尤其是 libgmp.其余的库通常在大多数 Linux 系统上都是开箱即用的.我相信 Windows 上的情况也类似.

GHC does produce stand-alone binaries that do not require GHC itself to be installed, however they do link against some dynamic libraries, most notably libgmp. The remaining libraries are commonly found out of the box on most Linux systems. I believe the situation is similar on Windows.

您可以在 Linux 上使用 ldd 检查您依赖的动态库.这是我在 Ubuntu Natty 上获得的一个简单的 Hello World 程序:

You can check which dynamic libraries you depend on using ldd on Linux. Here's what I get on Ubuntu Natty for a simple Hello World program:

$ echo 'main = putStrLn "Hello World"' > Hello.hs                                                   
$ ghc --make Hello.hs                                                                     
[1 of 1] Compiling Main             ( Hello.hs, Hello.o )
Linking Hello ...
$ ldd Hello                                                                                
    linux-vdso.so.1 =>  (0x00007fffe45ff000)
    libgmp.so.3 => /usr/lib/libgmp.so.3 (0x00007f8874cf9000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f8874a74000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f887486b000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f8874667000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f88742d3000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f88740b4000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f8874f7a000)

这篇关于ghc 编译的二进制文件是否需要 GHC 或者它们是独立的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆