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?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With