[HOpenGL] some general feedback re GHC and HOpenGL and apologies for the email i sent as ible_snover

John Sincock jss@au.mensa.org
Sat, 18 May 2002 01:08:53 +0930


hi andre,

i just noticed you did a make distclean which of course
already wipes the config.cache, so the suggestion i sent in 
as ible_snover was a duddo. oops. sorry

i just had another idea...  but doh! no, i just thought for a second
that you may have needed to remove some files in your 
ghc directory, but no, config.status, config.log and ghc.spec 
in your ghc build directory are probably removed by make distclean
and even if they arent, i just checked and they are certainly updated 
anyway when you re-run configure. So i have no idea, sorry. The 
problem you are having sounds really, really really weird. Good luck 
with the newer cygwin.

So since i dont have any other suggestions re your problem 
ill just give you ppl some feedback on how i found the 
whole ghc/HOpenGl make and install process, before i 
forget the minor problems which i did have. 

1) the ghc 5.02.3 source distribution didnt come with happy,
so i went and got it via CVS, and that fixed that.

2) the HOpenGL distributed with the ghc 5.02.3 source would 
not compile. After compiling and installing the ghc 5.02.3 compiler 
(with the 4.08 compiler booted up from .hc files), i re-ran configure
to use the ghc 5.02.3 compiler and also added the --enable-opengl 
and --with-glut-api=4 switches and tried to get HOpenGL 
compiled. But it failed, spitting the dummy as follows:

---------------------
==fptools== make all -wr;
 in /home/jss/stuff/src/haskell/ghc/builds/build5.02.3/hslibs/OpenGL
------------------------------------------------------------------------
rm -f GL/GL_Constants.o; if [ ! -d GL/GL_Constants ]; then mkdir 
GL/GL_Constants; else /usr/bin/find GL/GL_Constants -name '*.o' | xargs rm -f 
__rm_food; fi;   
/usr/local/bin/ghc -ldl -recomp -fvia-C -Wall -fglasgow-exts '-#include 
<GL/glut.h>'  -iGL -O  -I../lang/cbits -package-name OpenGL  -package lang 
-split-objs  -fno-warn-type-defaults -fno-warn-missing-signatures -cpp 
-fno-warn-unused-imports   -c GL/GL_Constants.hs -o GL/GL_Constants.o

GL/GL_Constants.hs:27:
    Type constructor or class not in scope: `HTYPE_GLENUM'

GL/GL_Constants.hs:30:
    Type constructor or class not in scope: `HTYPE_GLBOOLEAN'

GL/GL_Constants.hs:30:
    Type constructor or class not in scope: `HTYPE_GLBOOLEAN'

GL/GL_Constants.hs:284:
    Type constructor or class not in scope: `HTYPE_GLINT'

GL/GL_Constants.hs:284:
    Type constructor or class not in scope: `HTYPE_GLINT'

GL/GL_Constants.hs:284:
    Type constructor or class not in scope: `HTYPE_GLINT'

GL/GL_Constants.hs:531:
    Type constructor or class not in scope: `HTYPE_GLINT'

GL/GL_Constants.hs:531:
    Type constructor or class not in scope: `HTYPE_GLINT'

GL/GL_Constants.hs:531:
    Type constructor or class not in scope: `HTYPE_GLINT'

GL/GL_Constants.hs:531:
    Type constructor or class not in scope: `HTYPE_GLINT'

GL/GL_Constants.hs:545:
    Type constructor or class not in scope: `HTYPE_GLINT'

GL/GL_Constants.hs:548:
    Type constructor or class not in scope: `HTYPE_GLINT'

GL/GL_Constants.hs:548:
    Type constructor or class not in scope: `HTYPE_GLINT'

GL/GL_Constants.hs:633:
    Type constructor or class not in scope: `HTYPE_GLINT'

GL/GL_Constants.hs:654:
    Type constructor or class not in scope: `HTYPE_GLINT'

GL/GL_Constants.hs:654:
    Type constructor or class not in scope: `HTYPE_GLINT'

GL/GL_Constants.hs:753:
    Type constructor or class not in scope: `HTYPE_GLBITFIELD'

GL/GL_Constants.hs:753:
    Type constructor or class not in scope: `HTYPE_GLBITFIELD'

GL/GL_Constants.hs:753:
    Type constructor or class not in scope: `HTYPE_GLBITFIELD'

GL/GL_Constants.hs:753:
    Type constructor or class not in scope: `HTYPE_GLBITFIELD'
make[2]: *** [GL/GL_Constants.o] Error 1
make[1]: *** [all] Error 1
make[1]: Leaving directory 
`/home/jss/stuff/src/haskell/ghc/builds/build5.02.3/hslibs'
make: *** [all] Error 1
------------

3) no luck there, so i just downloaded the HOpenGL 1.2 source 
tarball, and the latest greencard tarball, compiled greencard and then 
had another go at compiling HOpenGL. And success ! all the examples
compiled successfully too.

4) the only other thing that bothered me a bit was when i went to test 
the whole thing by compiling BezMesh.hs

it just wasnt happening, as ghc was unable to locate GLUT as follows:

jss: /home/jss/stuff/src/haskell/opengl/BezMesh > ghc --make BezMesh.hs 
ghc-5.02.3: chasing modules from: BezMesh.hs
ghc-5.02.3: can't find module `GLUT'

I did a simple ghc -v and was rewarded with a list of the packages ghc 
was able to find, the last of which was:

----------
Package
   {name = "HOpenGL",
    import_dirs =
      ["/usr/local/ghc5.02.3/lib/ghc-5.02.3/imports/HOpenGL"],
    source_dirs = [],
    library_dirs = ["/usr/local/ghc5.02.3/lib/ghc-5.02.3"],
    hs_libraries = ["HOpenGL"],
    extra_libraries = [],
    include_dirs = [],
    c_includes = ["GL/glu.h"],
    package_deps = ["lang"],
    extra_ghc_opts = [],
    extra_cc_opts = ["-I/usr/X11R6/include"],
    extra_ld_opts =
      ["-lglut",
       "-lGLU",
       "-lGL",
       "-lSM",
       "-lICE",
       "-L/usr/X11R6/lib",
       "-lX11",
       "-lXext",
       "-lXmu",
       "-lXt",
       "-lXi",
       "-lm"]}
---------------

this had me pulling my hair out for a good 15 minutes or so. I couldnt 
believe i was so close, and yet still no donut. It didnt seem to make 
sense that my ghc was able to find the HOpenGL package, and 
yet not the GLUT.  I was boggling and virtually frothing at the mouth 
in frustration as the BezMesh.hs was first importing GL, which was 
apparently OK, and then importing GLUT, which was not OK.

I was especially horrified by this because ghc --help gives this:
-------
To compile and link a complete Haskell program, run the compiler like
so:

    ghc-5.02.3 --make Main

where the module Main is in a file named Main.hs (or Main.lhs) in the
current directory.  The other modules in the program will be located
and compiled automatically, and the linked program will be placed in
the file `a.out' (or `Main.exe' on Windows).
-----------

Then I found this, in the HOpenGL dist. :

---------
jss: /home/jss/stuff/src/haskell/ghc/HOpenGL-1.02 > less NEWS 
HOpenGL-1.02 is (again) mainly a compatibility release:

   * Added support for 3D textures: texImage3D, texSubImage3D,
     copyTexSubImage3D.

   * Added a "make install" target to add a HOpenGL package to GHC. This makes
     using HOpenGL much easier: A simple

        ghc -package HOpenGL --make MyCoolApp.hs

     is enough for most applications.
...
---------

that fixed the problem, ie ghc -package HOpenGL --make BezMesh.hs
succeeded.

I still dont know why the -package HOpenGL is necessary, but hey, its no 
big deal, i will probably work that out soon enough...  

All in all the install on linux went relatively painlessly, considering what
a huge and fearsome Beast the GHC is, and even HOpenGL aint 
exactly small either.

kudos to all you GHC and HOpenGL development ppl. Amazing job. 

ill shutup now,

john