Sometimes building a package with dependencies on OpenGL can be a little confusing for people new to Haskell. I will use a simple game on Hackage as an exercise for demonstrating how you might do this on Ubuntu. Note: this was written before Stack was a thing.

This is as much about demonstrating how to show your process as it is about how to install a game.

So our objective is to build and run a game named Shu-thing on Hackage.

First, I used cabal unpack to download the game's sources. Then I changed into the project directory and created my Cabal sandbox. To see more about how to use sandboxes, see my HowIStart tutorial.

Then, with the sandbox ready to go I started to install the dependencies for the project.

But it failed, something about needing a C library. My next step was to Google search "Missing C Library: GL" so I could find the resolution.

I chose the first link because it mentioned Gloss, which I know to be a Haskell library and thus likely relevant to my problem than a generic OpenGL issue. Realistically, any language would need to install the same OpenGL dependencies, but starting with the most specific questions/answers first is usually best.

There I saw instructions to install the appropriate GLUT dependencies for Debian/Ubuntu-alike distributions. I was using Ubuntu, so this suited me fine. This also matched what I knew about Shu-thing because its only dependency other than base was in fact GLUT.

This is me firing off those instructions.

Then I re-ran the dependencies install with cabal install --only-dependencies because that was the last thing to fail, and it succeeded. Next step was to build the executable for Shu-thing itself with cabal build. This also succeeded and reached the linking stage, which also didn't fail.

Then I checked the game out which had a nifty wireframe aesthetic :)

The point here is that I didn't know how to build this game or get it working 15 minutes before I started on this blog post and it wouldn't have done as much good to just dump a listing of instructions. Rather, it was more important "show my work", even if that entailed just googling for what dependencies I needed.

Like the way I share stuff? I'm working on a book with Julie Moronuki. Julie, in addition to editing and writing the book with me, is also testing our book with her 10 year old son. Check out the Haskell Programming book site to keep posted on what's going on. We've got a mailing list you can sign up for there if you want to know when the book is available for early access or final release.