How to create a program so that it does not require a DLL

How can I compile a program (Haskell) so that it does not require a DLL?

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 do not want it to require any DLLs (so I can just provide .exe for users). I tried to compile with ghc -static --make program.hs , but this did not work, I still get a "user error (unknown GLUT entry glutInit)".

How can i do this?

+6
compiler-construction dll linker haskell static-linking
source share
2 answers

This is only possible if GLUT provides a static version of the library (it can be called something like glut32s.lib , but there is no need for them to call it something specific).

The success of this approach will also depend on whether the GHC allows any link to external static libraries. The ghc page for ghc indicates that -static applies only to Haskell libraries, and not to other external libraries.

+3
source share

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 that Haskell components and C components are linked statically using the C toolchain.

+2
source share

All Articles