Skip to content

Trouble building applications with Haskell GLUT and freeglut on OS X with GHC 7.10.1 #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jtdaugherty opened this issue Apr 27, 2015 · 34 comments

Comments

@jtdaugherty
Copy link

When I depend on the GLUT Haskell package (2.6 or newer) on GHC 7.10.1 on OS X 10.9.5, the GLUT package builds and installs successfully, but applications that depend on GLUT fail during cabal install with this kind of linking error:

<command line>: can't load .so/.DLL for: .../.cabal-sandbox/lib/x86_64-osx-ghc-7.10.1/GLUT_99KmPk9UqZy96uvbsgIYcH/libHSGLUT-2.6.0.1-0sykGmIsSqkEsQwajDtfCI-ghc7.10.1.dylib (dlopen(.../.cabal-sandbox/lib/x86_64-osx-ghc-7.10.1/GLUT_99KmPk9UqZy96uvbsgIYcH/libHSGLUT-2.6.0.1-0sykGmIsSqkEsQwajDtfCI-ghc7.10.1.dylib, 5):
  Symbol not found: _glutBitmap8By13
  Referenced from: .../.cabal-sandbox/lib/x86_64-osx-ghc-7.10.1/GLUT_99KmPk9UqZy96uvbsgIYcH/libHSGLUT-2.6.0.1-0sykGmIsSqkEsQwajDtfCI-ghc7.10.1.dylib
  Expected in: flat namespace
 in .../.cabal-sandbox/lib/x86_64-osx-ghc-7.10.1/GLUT_99KmPk9UqZy96uvbsgIYcH/libHSGLUT-2.6.0.1-0sykGmIsSqkEsQwajDtfCI-ghc7.10.1.dylib)

I'm not sure whether this is GHC's fault or an interaction between OS X, GHC 7.10.1, etc., but this seemed like a good place to report this.

@jtdaugherty
Copy link
Author

It might also be worth mentioning that this occurs when trying to compile a module that uses template haskell.

@svenpanne
Copy link
Member

Do you have an example which fails without using TH?

@jakzale
Copy link

jakzale commented Apr 30, 2015

Same problem. GLUT 2.7.0.0, GHC 7.10.1, OSX 10.10.3.

Occurs when trying to load GLUT to GHCi.
$ ghci -package GLUT

I tried loading the OSX's GLUT.framework manually:
$ ghci -framework GLUT -package GLUT
but it produces the same error message.

To be sure I checked the OSX's GLUT.framework, it does contain the _glutBitmap8By13 symbol.

@svenpanne
Copy link
Member

OK, so this seems to be unrelated to TH and to the specific Mac OS X version. Do you have GHC 7.8.3 or 7.8.4 on your Mac to check if this is a GHC 7.10 regression? In the meantime I'll try to get 7.10 running on a Mac, but this might take some time, normally I develop on Windows + Linux only, so some help would be appreciated.

@jakzale
Copy link

jakzale commented May 1, 2015

I checked it under GHC 7.8.4 and
$ ghci -package GLUT
works fine (loads the package and shows the prompt).

@svenpanne
Copy link
Member

Thanks for the quick reply! So this really seems to be a GHC regression, and there's probably not much I can do about it. I'll try to find some hints in the various Haskell mailing lists, maybe there is some workaround. I don't think there's something special about GLUT, so other people probably already reported similar problems with other libraries.

@jtdaugherty
Copy link
Author

Thanks for looking into this, everyone! I haven't had time to respond since I originally filed this, and since it was unclear which piece of the toolchain was responsible for this issue, this seemed like a good guess as to where to file a bug and start looking. :)

@svenpanne, my intuition was also that this probably has nothing specifically to do with GLUT, and the situation isn't helped by the fact that googling for my specific linking error yields results that are non-Haskell-related and many years old.

I originally ran into this on a machine where GHC 7.8 worked fine but 7.10 yielded this behavior, to add to @jakzale's findings.

@svenpanne
Copy link
Member

The consensus seems to be that this is a GHC 7.8.4 => 7.10.1 regression, so I'll close this issue. If there are strong indicators that this is really caused by the GLUT package, then feel free to re-open this issue.

@Rydgel
Copy link

Rydgel commented Jun 21, 2015

@svenpanne So there is basically nothing I can do except rollback to 7.8.4?
Is there a bug report filled to GHC for this? I can make one if needed.

Can this be related to this: haskell/cabal#2330

@svenpanne
Copy link
Member

To be honest, I don't have a clue if this is a Cabal problem or a GHC problem, and I don't have a Mac to test any kind of hypothesis, So your best bet is to ask on the ghc-users mailing list and/or open a bug on GHC's trac and Cabal's issue tracker... :-/ It would be good to know what causes this, and if there is a workaround which I might be able to incorporate in the GLUT package.

@GeorgeCo
Copy link

Rydgel

It would be great if you could file a ghc bug for 7.10.1, putting the word regression in the subject and stating that we would like it fixed by 7.10.3. 7.10.2 is about to ship. I have a Mac and would be happy to also test any fixes from ghc

@Rydgel
Copy link

Rydgel commented Jun 24, 2015

This GHC bug looks a lot like our problem: https://ghc.haskell.org/trac/ghc/ticket/10322
Hopefully it is fixed in the soon to be released 7.10.2.

@rwbarton
Copy link

This is actually https://ghc.haskell.org/trac/ghc/ticket/10458, and not OS-specific.

@rwbarton
Copy link

Oops I didn't read carefully enough. It's actually a separate issue (and has already been filed as https://ghc.haskell.org/trac/ghc/ticket/10568).

@Rydgel
Copy link

Rydgel commented Jun 29, 2015

Just letting you guys know a small work-around found by darchon for now.
Reinstall GLUT like this:

cabal install GLUT --ghc-options="-optl-Wl,-framework,GLUT" --reinstall --jobs=1 

@svenpanne
Copy link
Member

OK, this confirms my theory about newer Cabals incorrectly dropping the GLUT framework during linking, although it is mentioned in GLUT's .cabal file.

@Rydgel
Copy link

Rydgel commented Jun 30, 2015

@svenpanne it's worse than that, there might be actually 2 bugs: https://ghc.haskell.org/trac/ghc/ticket/10568

@christiaanb
Copy link

Once https://phabricator.haskell.org/D1115 is merged in GHC, and haskell/cabal#2747 is merged in Cabal, this issue will be fixed.

@Rydgel
Copy link

Rydgel commented Aug 3, 2015

This is great news 👍
Thank you @christiaanb

@tmcdonell
Copy link

Recently I saw that it is not yet decided whether a ghc-7.10.3 release will actually happen, so perhaps we should make some noise over on the ghc mailing list to see this come to fruition. See also:

https://ghc.haskell.org/trac/ghc/wiki/Status/GHC-7.10.3

@svenpanne
Copy link
Member

That's a good idea, but at the moment I don't have access to a Mac, and I've lost track of which necessary changes are already in 7.10.2 and which ones aren't, so probably somebody with a Mac should make some noise. 😉

@mostlyfabulous
Copy link

I'm a Mac and it's not working in 7.10.2. Trying to use github builds to fix it until 7.10.3 is released.

@Rydgel
Copy link

Rydgel commented Nov 16, 2015

@mostlyfabulous they probably won't release a 7.10.3. You can use my work-around with 7.10.2 tho.

@mostlyfabulous
Copy link

@Rydgel I'm quite new to git. Would I just download the latest master of Cabal and install it with:

$ cabal install

and then do the same for GHC?

@Rydgel
Copy link

Rydgel commented Nov 16, 2015

Well you could probably do that yes. To me it seems easier to reinstall GLUT in the projects you need with:

cabal install GLUT --ghc-options="-optl-Wl,-framework,GLUT" --reinstall --jobs=1

Up to you.

@mostlyfabulous
Copy link

@Rydgel

Just to confirm, I wouldn't need to update Cabal from what you said right? All I have to do is reinstall with those flags?

Thanks for the help as well.

@Rydgel
Copy link

Rydgel commented Nov 16, 2015

@mostlyfabulous exactly, just regular GHC and cabal worked for me.

@mostlyfabulous
Copy link

Doesn't seem like those flags work with GHC 7.10.2. I get this error when I try to use GLUT.

*** Exception: user error (unknown GLUT entry glutInitDisplayMode)

This happens multiple times during cabal install:

"ld: warning: /System/Library/Frameworks//GLUT.framework/GLUT, ignoring unexpected dylib file" amongst other errors.

I'll add the log file here incase anyone knows what went wrong. I ran "otool -L" and put the log at the bottom of the file.

Reinstall of GLUT with flags.txt

@christiaanb
Copy link

@mostlyfabulous You can ignore that error, that error is about linking the profiling lib (which is static). That is, using --ghc-options="-optl-Wl,-framework,GLUT", you're basically saying: always link with the following options, regardless whether we're building a dynamically linked or statically linked binary.

The .dynlib, as the output of otool shows, is correctly linked against the system GLUT library:

Andrews-MacBook-Pro-4:Cabal Andrew$ otool -L /Users/Andrew/Library/Haskell/ghc-7.10.2-x86_64/lib/GLUT-2.7.0.3/libHSGLUT-2.7.0.3-2nuNqqOBahv0GxGnKzcdx6-ghc7.10.2.dylib
/Users/Andrew/Library/Haskell/ghc-7.10.2-x86_64/lib/GLUT-2.7.0.3/libHSGLUT-2.7.0.3-2nuNqqOBahv0GxGnKzcdx6-ghc7.10.2.dylib:
    @rpath/libHSGLUT-2.7.0.3-2nuNqqOBahv0GxGnKzcdx6-ghc7.10.2.dylib (compatibility version 0.0.0, current version 0.0.0)
    /System/Library/Frameworks/GLUT.framework/Versions/A/GLUT (compatibility version 1.0.0, current version 1.0.0)
    @rpath/libHSOpenGL-2.12.0.1-C0bfk5J7Xdm50tTCvVswN3-ghc7.10.2.dylib (compatibility version 0.0.0, current version 0.0.0)
...

and all is well with the world.

@mostlyfabulous
Copy link

@christiaanb Thanks very much for explaining what's going on!

I have no idea how to troubleshoot the errors I get from using the GLUT module now. I get this error when executing "main" for the Hello World example from: https://wiki.haskell.org/OpenGLTutorial1

*** Exception: user error (unknown GLUT entry glutInit)

And this error for executing "display (Go 30)" from a Haskell tutorial.

*** Exception: user error (unknown GLUT entry glutInitDisplayMode)

@christiaanb
Copy link

I'm seeing the same errors on my machine (OS X Yosemite). Indeed, the fixes I wrote for GHC and Cabal just made sure that the, as far as I knew, correct linker flags were passed. I never actually tested whether a GLUT application actually worked in ghci. My only test was to check if ghci -package GLUT worked, which it does.

This seems worthy of a new GHC bug report.

@mostlyfabulous
Copy link

I'm also running OS X Yosemite (10.10.5). Agreed, it definitely deserves a bug report!

@kaoskorobase
Copy link

Just for the record, in case you're using stack and until the bug is fixed, adding the following to stack.yaml should do the trick:

ghc-options:
  GLUT: -optl-Wl,-framework,GLUT

Then stack build and GLUT will be automatically recompiled with the new options.

@pablolob
Copy link

Hey guys. I am having the same issue: Exception: user error (unknown GLUT entry glutInit) but I have not been able to fix it. I am on windows and I used cabal to install. Any tip?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests