user1214949
user1214949

Reputation:

Haskell - Issue Compiling in GHC

I'm very new to Haskell, and I've recently installed the platform with GHC. I decided to test it out by compiling a simple Hello world program: main = putStrLn "Hello, world"

Now, when I go into the command line (Windows 7), find the proper directory, and type in ghc hello.hs, it comes back with the following message: "[1 of 1] Compiling Main ( hello.hs, hello.o )". I understand that once it's done compiling, it should follow with "Linking hello.exe ...", but that never comes, and no .exe is produced.

Basically, is there any discernible reason why this would be happening? Is there a problem with the code, is there something I don't know about, or should I just try re-installing the Haskell Platform?

Thank you.

Upvotes: 14

Views: 2833

Answers (3)

Ari P
Ari P

Reputation: 293

I got ghc to link my program into an executable by removing module declaration from the start of the file.

Upvotes: 15

MathematicalOrchid
MathematicalOrchid

Reputation: 62848

I would use the --make option, as in ghc --make hello.hs. (You can actually leave out the file extension if you like.) This will automatically figure out what needs to be done, which packages if any need to be linked in, and generally do everything you'd expect.

Upvotes: 1

ikuramedia
ikuramedia

Reputation: 6058

Has it produced an a.exe or a.out.exe or a.out file instead? If not, then maybe you can just link it yourself? ld -o hello.exe hello.o or whatever the link command is on your platform.

Upvotes: 1

Related Questions