Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
796 views
in Technique[技术] by (71.8m points)

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

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, Windows, and Linux?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

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)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

Just Browsing Browsing

[5] html - How to create even cell spacing within a

1.4m articles

1.4m replys

5 comments

57.0k users

...