bug: "Exception: user error (unknown GLUT entry glutInit)" under ghci, but not when compiled (Linux)

785 views
Skip to first unread message

Eugene Crosser

unread,
Aug 24, 2019, 6:19:18 AM8/24/19
to Haskell Gloss
I've sent it to the bug reporting channel (email) specified in the package, but there was now reaction and it did not appear in trak. On github, bug tracker is disabled. So I am copying the report here:

=====
Linux Ubuntu eoan,
ghc 4.8.8, libghc-gloss-dev 1.13.0.1-2build1, freeglut3 2.8.1-3

Running example from the package description:


```
$ cat g.hs
import Graphics.Gloss
main = display (InWindow "Nice Window" (200, 200) (10, 10)) white (Circle 80)
```

When compiled, works as expected:

```
$ ghc --make g.hs && ./g
```

shows the window with the circle. However, when run under ghci it does not work:


```
$ ghci g.hs
GHCi, version 8.4.4: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( g.hs, interpreted )
Ok, one module loaded.
*Main> :main
*** Exception: user error (unknown GLUT entry glutInit)
*Main>
```

It is quite unfortunate to not be able to debug the code under ghci.

Thanks,

Eugene

Ben Lippmeier

unread,
Aug 24, 2019, 6:21:54 AM8/24/19
to haskel...@googlegroups.com, Eugene Crosser
Try starting ghci with -fasm and -fno-ghci-sandbox. Using Gloss + GLUT under ghci has never been completely stable. It tends to work on some platforms but not others. You could also try to use the GLFW wrapper using the instructions on http://gloss.ouroborus.net/

Ben.


--
You received this message because you are subscribed to the Google Groups "Haskell Gloss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haskell-glos...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/haskell-gloss/94a7d12d-37c1-4f6b-bafb-4bcd80137cec%40googlegroups.com.

Eugene Crosser

unread,
Jan 14, 2021, 5:11:24 PM1/14/21
to Haskell Gloss
It's been a long time!
But today I was frustrated by this problem again, and tried something that seems obvious in retrospect, i.e. use LD_PRELOAD to load libglut when starting ghci. And it worked!  So, there is a workaround for this problem. In my case (Ubuntu groovy), the command looks like this:

    LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libglut.so.3 ghci ...

After that, it is possible to run (`:main ...`) the application from ghci. Hope that this may help somebody.
Reply all
Reply to author
Forward
0 new messages