Jerry
Jerry

Reputation: 1149

How to build a program so that it doesn't require DLLs

How can I compile a (Haskell) program so that it doesn't require DLLs?

I wrote a program that uses GLUT and requires glut32.dll. I compiled it with ghc --make program.hs. Now I want to distribute my program, but I don't want it to require any DLLs (so I can just give the .exe to the users). I tried compiling with ghc -static --make program.hs but it didn't work, I still get "user error (unknown GLUT entry glutInit)".

How can I do this?

Upvotes: 6

Views: 599

Answers (2)

Don Stewart
Don Stewart

Reputation: 137987

Assuming you have static versions of the required C libraries, you can create a static Haskell executable with:

 ghc -O2 --make -static -optc-static -optl-static A.hs -fvia-C

which ensures both the Haskell components, and C components will be linked statically, via the C toolchain.

Upvotes: 2

Greg Hewgill
Greg Hewgill

Reputation: 994231

This is only possible if GLUT provides a static version of the library (this could be named something like glut32s.lib but there's no requirement that they call it anything in particular).

The success of this approach will also depend on whether GHC allows linking with external static libraries at all. The man page for ghc indicates that -static applies only to the Haskell libraries, not other external libraries.

Upvotes: 3

Related Questions