GHC and Gloss on OpenBSD

GHC and Gloss on OpenBSD

I use gloss for most Haskell projects. Using gloss it is really simple to get something working with simple graphics.

Gloss works great on OpenBSD 5.5 (amd64) with some minor tweakings.

Install GHC

  • Download new version
  • Update cabal

Install Gloss

I had to install llvm and link to opt and llc from /usr/local/bin to make gloss-raster work. XCode includes LLVM but not these tools it seems. This is dependent on -fllvm options in gloss-raster package. See GHC Backends.

Examples are available under


gloss-visibility does exactly what I want in this game!

Install Gloss on OpenBSD 5.5 (amd64)

Gloss installs without any problems.

cabal install gloss

But gloss-examples which is dependent on gloss-raster doesn’t work.

After installing LLVM the opt and llc is available under /usr/local/bin, but that doesn’t help.

pkg_add llvm

I get the following error.

You are using a new version of LLVM that hasn't been tested yet!
We will try though...
/tmp/ghc1773_0/ghc1773_0.s: Assembler messages:

     Error: can not do 8 byte pc-relative relocation

I tried to upgrade cabal and install with that instead, but I get the same error.

cabal install cabal-install
/root/.cabal/bin/cabal install gloss-raster

Instead of using the -fllvm option you can use the default asm backend with -fasm which seems to work fine. The other standard options in gloss-raster.cabal have also been added.

cabal install --ghc-options="-Odph -fno-liberate-case -fasm -optlo-O3" gloss-raster

And for gloss-examples.

cabal install --ghc-options="-fasm" gloss-examples

But, then you are missing a lot of options in gloss-examples.cabal

Install on 5.9 snapshot

cabal install gloss --flags="GLUT -GLFW" --extra-include-dirs="/usr/X11R6/include" --extra-lib-dirs="/usr/X11R6/lib"

Install on 6.0

FIRST make sure wxallowed is set on /home. Strange errors happen otherwise!

Install haskell platform and haskell package for OpenGL.

$ pkg_info -m | grep Haskell 
haskell-platform-7.10.3p0v0 Haskell platform meta-package
hs-GLUT-   Haskell binding for the OpenGL Utility Toolkit

Gloss install without any problems. Constraint may not be neccesary.

$ cabal --reinstall install bmp
$ cabal install -f"glut -glfw" gloss --constraint=gloss==

Install gloss-raster

$ cabal install -f"glut -glfw" gloss-raster

Install gloss-juicy

cabal install gloss-juicy