This post is really informative of what I'm trying to achieve. I created a simple HelloUnix binary.
$ echo 'main = putStrLn "Hello Unix"' > HelloUnix.hs $ ghc -static --make HelloUnix.hs
What created the HelloUnix binary, I was hoping the -static flag would all link inside the binary, so all that was needed to run the binary was the file itself. I transferred the binary to another unix machine, making sure that the file has the correct access privilege via chmod . Called binary, but this error appeared
bash: ./HelloUnix: cannot execute binary file
Any ideas on how to debug this?
EDIT: I'm currently trying to develop a distributed system, so I was hoping to just distribute the binaries to the target machines. I need a way to run the binary, even though it is running, which is the target anyway.
EDIT2: Source:
mike@mike-1215B :~/Haskell_Program/SmallApp/HelloUnix$ uname -a Linux mike-1215B 3.0.0-13-generic
Remote Machine 1:
[ hchiao@rimmer ] hchiao [1:59] uname -a SunOS rimmer 5.9 Generic_122301-48 i86pc i386 i86pc [ hchiao@rimmer ] hchiao [1:60] file HelloUnix HelloUnix: ELF 64-bit LSB executable Version 1, dynamically linked, not stripped
Remote Machine 2:
ubuntu@ip-10-240-88-224 :~/cloud-haskell$ uname -a Linux ip-10-240-88-224 3.2.0-36-virtual
EDIT3: Now I am compiling the code in machine 2 and trying to run the binary on machine 1. I assume that they are both i386, so the binary should work on another machine. However, I get this error:
HelloUnix: Cannot find /lib/ld-linux.so.2 Killed
I think this tells me that the library ( ld-linux.so.2 ) that the binary depends on (maybe dynamic linking?) Is not on my target machine. Am I a little confused about what the -static flag did? I assumed that with the flag all dependencies will be combined into a binary file. What would be the best way to make Haskell portable code?