
Hello, I've been experimenting with HOpenGL a little, and have run into strange behaviour when compiling with -O. In particular, while things work as expected when compiling normally, if I compile the following module with -O, drawLine' appears to scale the line by 2, while drawLine works as before. module Lines where import GL drawLine = do pushMatrix beginEnd Lines . sequence_ . map vertex $ [ Vertex2 0 0, Vertex2 0 (1::GLfloat) ] popMatrix drawLine' = do pushMatrix scale 1 1 (1::GLfloat) beginEnd Lines . sequence_ . map vertex $ [ Vertex2 0 0, Vertex2 0 (1::GLfloat) ] popMatrix This was tested using the attached program. I'm using HOpenGL-1.01 with the recent patch, and a ghc from CVS which is about a week old. When compiling Lines.hs with -O, I get /tmp/ghc14725.hc: In function `s8Wy_ret': /tmp/ghc14725.hc:474: warning: implicit declaration of function `glScalef' Also, if I actually compile the test program with -O, it doesn't display anything.

[...] appears to scale the line by 2, [...]
When compiling Lines.hs with -O, I get
/tmp/ghc14725.hc: In function `s8Wy_ret': /tmp/ghc14725.hc:474: warning: implicit declaration of function `glScalef'
Compilation with -O makes GHC compile via the C compiler. GHC should
have been told
to #include

Wolfgang Thaller wrote:
[...] Not exactly a solution, but it should explain the problem...
Yep, it looks like a missing header problem. A better solution would be telling your ghc about a HOpenGL package. Assuming you have successfully compiled HOpenGL at /my/home/dir/HOpenGL-1.01, create a package configuration file HOpenGL.conf containing: --SNIP----SNIP----SNIP----SNIP----SNIP----SNIP----SNIP----SNIP----SNIP-- [Package {name = "HOpenGL", import_dirs = ["/my/home/dir/HOpenGL-1.01/lib"], source_dirs = [], library_dirs = ["/my/home/dir/HOpenGL-1.01/lib"], hs_libraries = ["HOpenGL"], extra_libraries = [], include_dirs = [], c_includes = ["GL/glut.h"], package_deps = ["base"], 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"]}] --SNIP----SNIP----SNIP----SNIP----SNIP----SNIP----SNIP----SNIP----SNIP-- Your mileage may vary with the extra_ld_opts, have a look at GL_LIBS in your /my/home/dir/HOpenGL-1.01/config.mk to see what configure found about those. Then you have the option of making HOpenGL globally know to ghc via ghc-pkg --add-package < HOpenGL.conf and use "-package HOpenGL" or add -package-conf HOpenGL.conf -package HOpenGL to the ghc flags for your example to make it known locally only, see http://haskell.org/ghc/docs/latest/set/packages.html#PACKAGE-MANAGEMENT Things like this are currently all a bit messy, I know, but libraries, package handling, GLU versions etc. are a constantly moving target. After HOpenGL's rewrite this will definitely improve... Have fun rendering, S.

[...] Not exactly a solution, but it should explain the problem...
Yep, it looks like a missing header problem. A better solution would be telling your ghc about a HOpenGL package. Assuming you have successfully compiled HOpenGL at /my/home/dir/HOpenGL-1.01, create a package configuration
Thanks to both of you. It compiles fine by hand, and I'll have a look at the package configuration later. Cheers, Robert
participants (3)
-
Robert Vollmert
-
Sven Panne
-
Wolfgang Thaller