haskell-opengl / OpenGL

Haskell bindings to OpenGL
http://www.haskell.org/haskellwiki/OpenGL
BSD 3-Clause "New" or "Revised" License
147 stars 26 forks source link

Build Error on Mavericks ... Missing GL Extensions ? #73

Closed barnabyrobson closed 9 years ago

barnabyrobson commented 9 years ago
Configuring OpenGL-2.9.2.0...
Building OpenGL-2.9.2.0...
Preprocessing library OpenGL-2.9.2.0...
[  1 of 117] Compiling Graphics.Rendering.OpenGL.GL.VertexAttributes ( Graphics/Rendering/OpenGL/GL/VertexAttributes.hs, dist/build/Graphics/Rendering/OpenGL/GL/VertexAttributes.o )
[  2 of 117] Compiling Graphics.Rendering.OpenGL.GL.Texturing.Filter ( Graphics/Rendering/OpenGL/GL/Texturing/Filter.hs, dist/build/Graphics/Rendering/OpenGL/GL/Texturing/Filter.o )
[  3 of 117] Compiling Graphics.Rendering.OpenGL.GL.PointParameter ( Graphics/Rendering/OpenGL/GL/PointParameter.hs, dist/build/Graphics/Rendering/OpenGL/GL/PointParameter.o )
[  4 of 117] Compiling Graphics.Rendering.OpenGL.GL.PixelFormat ( Graphics/Rendering/OpenGL/GL/PixelFormat.hs, dist/build/Graphics/Rendering/OpenGL/GL/PixelFormat.o )

Graphics/Rendering/OpenGL/GL/PixelFormat.hs:82:12:
    Not in scope: ‘gl_ABGR’
    Perhaps you meant one of these:
      ‘gl_BGR’ (imported from Graphics.Rendering.OpenGL.Raw),
      ‘gl_BGRA’ (imported from Graphics.Rendering.OpenGL.Raw)

I have a Mac mini (Late 2014) Intel Iris Graphics .... so I must have all the right GL extensions ... but my build isn't picking them up. My GHC settings are already set to use a non clang gcc so ... anything else I can try ? Thanks !

svenpanne commented 9 years ago

Hmmm, for some reason you seem to have a rather recent version of OpenGLRaw (>= 2.1.0.0), but a rather old version of OpenGL (2.9.2.0). These don't work together, so I added an upper bound on the version of OpenGL just now. Could you do a cabal update, retry your compilation and report if that worked?

Regarding your hardware: Compilation of the OpenGL-related packages don't depend on the OpenGL capabilities of your platform, things are handled dynamically at runtime.

elisehuard commented 9 years ago

hmmm, had the same error as @barnabyrobson originally, did cabal update, but different error this time

Graphics/Rendering/OpenGL/GL/Texturing/Specification.hs:302:44:
Couldn't match type ‘Foreign.C.Types.CInt’
              with ‘Foreign.C.Types.CUInt’
Expected type: GLenum
  Actual type: GLint
In the third argument of ‘glTexImage2DMultisample’, namely
  ‘(marshalPixelInternalFormat int)’
In the expression:
  glTexImage2DMultisample
    (marshalMultisample proxy target)
    s
    (marshalPixelInternalFormat int)
    w
    h
    (marshalSampleLocations loc)

Graphics/Rendering/OpenGL/GL/Texturing/Specification.hs:319:44:
Couldn't match type ‘Foreign.C.Types.CInt’
              with ‘Foreign.C.Types.CUInt’
Expected type: GLenum
  Actual type: GLint
In the third argument of ‘glTexImage3DMultisample’, namely
  ‘(marshalPixelInternalFormat int)’
In the expression:
  glTexImage3DMultisample
    (marshalMultisample proxy target)
    s
    (marshalPixelInternalFormat int)
    w
    h
    d
    (marshalSampleLocations loc)

looks like some signatures changed

elisehuard commented 9 years ago

Fixing OpenGLRaw's version number in my project fixes it (even though I don't use it explicitly):

OpenGLRaw == 1.5.0.0
barnabyrobson commented 9 years ago

Thanks ! .. I got a little further this time.

cabal install opengl==2.9.2.0
...
[ 75 of 117] Compiling Graphics.Rendering.OpenGL.GL.Texturing.Specification ( Graphics/Rendering/OpenGL/GL/Texturing/Specification.hs, dist/build/Graphics/Rendering/OpenGL/GL/Texturing/Specification.o )

Graphics/Rendering/OpenGL/GL/Texturing/Specification.hs:302:44:
    Couldn't match type ‘Foreign.C.Types.CInt’
                  with ‘Foreign.C.Types.CUInt’
    Expected type: GLenum
      Actual type: GLint
    In the third argument of ‘glTexImage2DMultisample’, namely
      ‘(marshalPixelInternalFormat int)’
    In the expression:
      glTexImage2DMultisample
        (marshalMultisample proxy target)
        s
        (marshalPixelInternalFormat int)
        w
        h
        (marshalSampleLocations loc)

If you are curious why I'm installing an older version of OpenGL it's because I need gloss which is dependent on the 2.9 series.

svenpanne commented 9 years ago

Cabal hell... What I did was the following: I released new versions of the OpenGLRaw package (2.x with 2.3.0.0 the most recent, most of it automatically generated, full support for all OpenGL versions and extensions), which has a slightly different API. I released a new version (2.10.0.2) of the OpenGL package which works with the new OpenGLRaw package, the 2.9.x version of OpenGL do not work with the new OpenGLRaw. The latter problem should have been fixed by adding an upper bound to OpenGL-2.9.2.0.

To figure out what's still going wrong: Could you please build your stuff in a Cabal sandbox and post what exactly goes wrong (including all cabal output) and the output of cabal exec ghc-pkg list? That would help a lot.

svenpanne commented 9 years ago

tl;dr Just do a cabal update again and re-try.

OK, I've tweaked a few more version bounds on Hackage, and I've successfully built gloss with all its OpenGL-related packages. Because the version bounds in the gloss package are very strict, you get old versions of OpenGL-related packages:

$ cabal install gloss --constraint="OpenGL source" --constraint="GLURaw source" --constraint="OpenGLRaw source" --constraint="GLUT source"
Resolving dependencies...
In order, the following will be installed:
OpenGLRaw-1.5.0.1 (latest: 2.3.0.0) (new version)
GLURaw-1.4.0.2 (new version)
OpenGL-2.9.2.0 (latest: 2.10.0.2) (reinstall) changes: GLURaw-1.4.0.1 ->
1.4.0.2, OpenGLRaw-1.5.0.0 -> 1.5.0.1
GLUT-2.5.1.1 (latest: 2.6.0.1) (reinstall) changes: OpenGLRaw-1.5.0.0 ->
1.5.0.1
bmp-1.2.5.2 (new package)
gloss-rendering-1.9.2.1 (new package)
gloss-1.9.2.1 (new package)
Warning: Note that reinstalls are always dangerous. Continuing anyway...
Notice: installing into a sandbox located at D:\Repositories\test-sandbox
Downloading OpenGLRaw-1.5.0.1...
Downloading bmp-1.2.5.2...
Configuring bmp-1.2.5.2...
Configuring OpenGLRaw-1.5.0.1...
Building bmp-1.2.5.2...
Building OpenGLRaw-1.5.0.1...
Installed bmp-1.2.5.2
Installed OpenGLRaw-1.5.0.1
Downloading GLURaw-1.4.0.2...
Configuring GLURaw-1.4.0.2...
Building GLURaw-1.4.0.2...
Installed GLURaw-1.4.0.2
Downloading OpenGL-2.9.2.0...
Configuring OpenGL-2.9.2.0...
Building OpenGL-2.9.2.0...
Installed OpenGL-2.9.2.0
Downloading GLUT-2.5.1.1...
Configuring GLUT-2.5.1.1...
Building GLUT-2.5.1.1...
Installed GLUT-2.5.1.1
Downloading gloss-rendering-1.9.2.1...
Configuring gloss-rendering-1.9.2.1...
Building gloss-rendering-1.9.2.1...
Installed gloss-rendering-1.9.2.1
Downloading gloss-1.9.2.1...
Configuring gloss-1.9.2.1...
Building gloss-1.9.2.1...
Installed gloss-1.9.2.1

The --constraint flags were necessary for me locally to tell Cabal that I don't want the packages from the Haskell Platform (which I have installed). Otherwise it would just install bmp, gloss-rendering, and gloss. For you (obviously without the HP), a simple cabal install gloss should work now. Please drop a note here if that's actually the case, and if not, how to reproduce.

I'm a bit unhappy about the Cabal hell: If all version bounds are very tight (see gloss), Cabal might not find an install plan and/or install ancient packages, if version bounds are too loose (see OpenGL), compilation might break. :worried:

barnabyrobson commented 9 years ago

Problem solved ! Thank you very much :)

I hear what you are saying about the Cabal Hell. I suppose that it's not the worst thing in the world to always specify the exact versions of packages that you can confirm work together. If you don't and have no upper bound then the best that can happen is that your downloaders maybe get bug fixes and performance (& security?) improvements from upstream packages for free but the worst that can happen is that your package completely breaks so it's a tradeoff.

elisehuard commented 9 years ago

Building Gloss works for me now! Thanks! (and cabal hell indeed :/ - I can see it's a difficult one for package maintainers)