elisehuard / game-in-haskell

Other
119 stars 30 forks source link

ERROR: Function <glutStrokeCharacter> called without first calling 'glutInit' #1

Open ludflu opened 9 years ago

ludflu commented 9 years ago

after successfully building everything in the sandbox, running the executable fails like this:

jsnavely@beefy ~/project/game-in-haskell (master)$ cabal run shapes-demo Preprocessing executable 'shapes-demo' for game-in-haskell-book-0.1.0.0... freeglut ERROR: Function called without first calling 'glutInit'.

I'm running GHC 7.8.3 on Ubuntu 14.04.1 LTS

I can, however, run the frp-demo without encountering the error until after the program exits.

dino- commented 9 years ago

I'm seeing this as well, same as above. GHC 7.8.4 on Arch Linux.

jmillikan commented 9 years ago

Same issue, Ubuntu 14.04 LTS; I hacked around it by explicitly initializing GLUT and made a pull request for it, but the hacked is probably not compatible with all systems.

yuvallanger commented 9 years ago

@jmillikan Could you link to your patch and explain a bit how to use it?

jmillikan commented 9 years ago

@yuvallanger It's this pull request pointing to this commit. It's built and run the same as the original, but here's the short version assuming not a lot of prior knowledge.

I'm actually on a new box, so I'm filling in the details here while doing it. I have GHC 7.8.4 and Cabal 1.22.0.0 (library the same) installed from binaries, but Haskell Platform 2014.2.0.0 also works.

First, you'll need some externals - on Ubuntu, try sudo apt-get install freeglut3 freeglut3-dev libalut0 libalut-dev. Until you have them all, the cabal build will fail with semi-helpful messages.

Clone my repository and switch to the hacky branch: git clone https://github.com/jmillikan/game-in-haskell.git && git checkout ubuntu-glut-backend.

In the root of that (with the .cabal file), make a sandbox and build the demos in it: cabal sandbox init && cabal install and watch das blinkenlights.

Once finished, you should find all the working demos in .cabal-sandbox/bin, e.g. ./.cabal-sandbox/bin/frp-demo should end correctly with the Game Over message! (It still has to be killed manually.)

And, to re-iterate, this is just a hack that makes very little sense, but lets you work the examples in Linux.