Wow, what an interesting bunch of reads.  I still haven't tried the options yet as I dont work with windows too much.  What was the consensus? on the steps to follow.  I will try finding a freeglut dll and then changing the name to 
opengl32.dll and see if that works.<br><br><div><span class="gmail_quote">On 9/23/07, <b class="gmail_sendername">Ronald Guida</b> &lt;<a href="mailto:ronguida@mindspring.com">ronguida@mindspring.com</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Sven Panne wrote:<br> &gt; On Friday 21 September 2007 20:19, Ronald Guida wrote:<br> &gt;&gt; John Wicket wrote:
<br> &gt;&gt;&nbsp;&nbsp;&gt; yea, that is probably what I need.&nbsp;&nbsp;Can you post in a<br>step-by-step way.<br> &gt;&gt;<br> &gt;&gt; Here is a set of instructions for what I had to do to get FreeGLUT<br> &gt;&gt; working with GHCi [...].
<br> &gt;<br> &gt; Oh dear, a long a sad story... :-(<br><br>And frustrating too.&nbsp;&nbsp;:-)<br><br> &gt;&gt; [...]&nbsp;&nbsp;Although I just don&#39;t understand why freeglut, the<br> &gt;&gt; Haskell GLUT library, and GHCi won&#39;t work together in the first place.
<br> &gt;<br> &gt; That statement is not correct, they *do* work together. The problem<br>you are<br> &gt; experiencing is that the GLUT version used to build the GHC<br>installer/binary<br> &gt; distro is obviously not freeglut, but &quot;classic&quot; GLUT. As long as you
<br>only<br> &gt; use &quot;classic&quot; GLUT features, this is OK. Things get really hairy when<br>you<br> &gt; want to use freeglut-only features and still have a GHC installer/binary<br> &gt; distro which is guaranteed to run with &quot;classic&quot; GLUT as well (with
<br> &gt; restricted features in the latter case, of course). To do this<br>properly, the<br> &gt; GLUT package has to resolve freeglut-only API entries dynamically, but<br> &gt; glutGetProcAddress is not contained in lots of GLUT DLLs out in the wild
<br> &gt; (it&#39;s in GLUT API version 5 plus freeglut). This is really a pity and<br>a big<br> &gt; design flaw in GLUT IMHO, but there is not much one can do about<br>that.The<br> &gt; only thing left is to load the GLUT/freeglut dynamic library,
<br> &gt; well, &quot;dynamically&quot; and resolve the freeglut API entries by hand.<br>Doing this<br> &gt; is not hard, but a little bit tricky to get right portably: Use<br>dlopen/dlsym<br> &gt; on most *nices, LoadLibrary/GetProcAddress on Windoze, something else
<br>on Mac<br> &gt; OS, take care of possible leading underscores, etc. etc. I really<br>wanted to<br> &gt; avoid doing this, but it looks like there is no way around it. Given the<br> &gt; current time frame for the GHC 
6.8.1 release, I don&#39;t think that it is<br> &gt; feasible to get this into that release, because I would need feedback<br>from<br> &gt; lots of platforms to be sure things work.<br><br>In fact, when I compiled freeglut with MSVC, it compiled successfully
<br>&quot;out of the box&quot;.&nbsp;&nbsp;When I tried to use my new freeglut.dll with GHCi,<br>I got linker errors all over the place and I eventually discovered<br>that the problem involves leading underscores.<br><br> &gt;&gt; [...] 
darcs-1.0.9<br> &gt;&gt;&nbsp;&nbsp; <a href="http://darcs.net/darcs-1.0.9.tar.gz">http://darcs.net/darcs-1.0.9.tar.gz</a> [...]<br> &gt;<br> &gt; There are darcs binaries for Windows, so there is no need to build it<br>and the<br>
 &gt; libraries it needs:<br> &gt;<br> &gt;<br><a href="http://wiki.darcs.net/DarcsWiki/CategoryBinaries#head-c7910dd98302946c671cf63cb62712589b392074">http://wiki.darcs.net/DarcsWiki/CategoryBinaries#head-c7910dd98302946c671cf63cb62712589b392074
</a><br><br>Ooo, Thank you!&nbsp;&nbsp;;-)<br><br> &gt; Furthermore, darcs itself is not needed for what you want to do.<br> &gt;<br> &gt;&gt; [...] Freeglut-2.4.0<br> &gt;&gt;&nbsp;&nbsp; <a href="http://freeglut.sourceforge.net/index.php#download">
http://freeglut.sourceforge.net/index.php#download</a> [...]<br> &gt;<br> &gt; The freeglut project currently doesn&#39;t provide prebuilt binaries, so<br>this is<br> &gt; hardly the GLUT package&#39;s fault. ;-) Furthermore, the official way to
<br>build<br> &gt; the project on Windows is via MSVC, and there are projects files for<br>this.<br> &gt; Building a DLL via MinGW/MSYS would be nice, too, so perhaps you<br>could post<br> &gt; your patches in the freeglut-developer mailing list. I think that
<br>there will<br> &gt; be a new freeglut release soon, perhaps I can push people to make at<br>least a<br> &gt; simple ZIP file with the binaries for Windows available on the<br>project pages.<br> &gt;<br> &gt;&gt; GLUT-2.1.1
<br> &gt;&gt;&nbsp;&nbsp; You need to use darcs to download GLUT-2.1.1.<br> &gt;&gt; [...]<br> &gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Locate the line start starts with &quot;build-depends:&quot; and remove<br> &gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the dependencies &quot;array&quot; and &quot;containers&quot;
<br> &gt;<br> &gt; Now you enter the great world of Cabal versionits and the Big Library<br>Splitup<br> &gt; (tm). ;-) If you want to use a bleeding edge version of GLUT, you need a<br> &gt; bleeding edge version of GHC and the libraries coming with it. A
<br>released<br> &gt; version is available via <a href="http://hackage.haskell.org">hackage.haskell.org</a>.<br><br>Rumor: Version-itis and the big library splitup are going to break<br>everyone&#39;s existing code!&nbsp;&nbsp;:-O<br>
<br> &gt;&gt;&nbsp;&nbsp; [...] 6. Modify &quot;GLUT-2.1.1/Graphics/UI/GLUT/Extensions.hs&quot; as<br>follows:<br> &gt;&gt;<br> &gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Look at the last two lines:<br> &gt;&gt;<br> &gt;&gt; foreign import ccall unsafe &quot;hs_GLUT_getProcAddress&quot;
<br>hs_GLUT_getProcAddress<br> &gt;&gt;<br> &gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;:: CString -&gt; IO (FunPtr a)<br> &gt;&gt;<br> &gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Change &quot;hs_GLUT_getProcAddress&quot; to &quot;glutGetProcAddress&quot;<br> &gt;&gt;<br> &gt;&gt;&nbsp;&nbsp; 7. Modify &quot;
GLUT-2.1.1/cbits/HsGLUT.c&quot; as follows:<br> &gt;&gt;<br> &gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Look for &quot;void* hs_GLUT_getProcAddress(char *procName)&quot; and<br> &gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;remove the whole function.<br> &gt;<br> &gt; Huh? If you *really* compile against the freeglut header, these steps
<br>are<br> &gt; unnecessary. What is the reason for this change?<br><br>The reason for this change is that I had reached the point where I had<br>one remaining linker error.&nbsp;&nbsp;I found that hs_GLUT_getProcAddress is a<br>stub that calls the real glutGetProcAddress, and I figured out that
<br>this call to the real glutGetProcAddress was refusing to link.&nbsp;&nbsp;I made<br>the determination that (1) the stub is there to fix a broken<br>glutGetProcAddress, and (2) mine isn&#39;t broken.&nbsp;&nbsp;Therefore, instead of<br>trying to find the cause of the linker error, I decided to avoid the
<br>error entirely by removing the stub and calling directly to the real<br>thing.<br><br> &gt;&gt; {...]<br> &gt;&gt;&nbsp;&nbsp; 11. In GHC&#39;s directory, there is a file named &quot;package.conf&quot;.&nbsp;&nbsp;This<br> &gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; file contains one extremely long line.&nbsp;&nbsp;You need to find an
<br> &gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; editor that will let you insert some text into this line without<br> &gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; introducing any line breaks.&nbsp;&nbsp;Emacs can do this.<br> &gt;&gt;<br> &gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; You need to locate the text &lt;&lt; pkgName = &quot;GLUT&quot; &gt;&gt; and then you
<br> &gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; need to locate &lt;&lt; hsLibraries = [&quot;HSGLUT-2.1.1&quot;] &gt;&gt; to the right<br> &gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; of there.&nbsp;&nbsp;The very next thing to the right of &quot;hsLibraries&quot;<br> &gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; should be &lt;&lt; extraLibraries = [] &gt;&gt;.&nbsp;&nbsp;You need to change it to
<br> &gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;&lt; extraLibraries = [&quot;freeglut&quot;] &gt;&gt;.<br> &gt;<br> &gt; This is unnecessary if you install the freeglut DLL correctly. What<br>is the<br> &gt; output of &quot;ghc-pkg describe GLUT&quot; before this modification?
<br><br>By this time, I have bypassed the correct installation of freeglut.<br><br> &gt;&gt;&nbsp;&nbsp; 13. If you want to /compile/ with GHCi, then you&#39;ll need to copy the<br> &gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; freeglut.dll file into the same directory as your newly-compiled
<br> &gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; program.exe file.&nbsp;&nbsp;I haven&#39;t tried static linking yet; that<br> &gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; would require recompiling freeglut as a static library instead<br> &gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; of a DLL.<br> &gt;<br> &gt; The &quot;traditional&quot; way is to put the DLL as &quot;
glut32.dll&quot; into your<br> &gt; WINDOWS/system32, just next to opengl32.dll. :-P I don&#39;t know what the<br> &gt; Vista-approved way of doing this is, and probably the freeglut<br>project needs<br> &gt; an installer. Any volunteers?
<br><br>The issue here is DLL Hell.&nbsp;&nbsp;I now have two versions of the freeglut<br>DLL.&nbsp;&nbsp;One of them came from MSVC and the other came from my hacking.<br>Neither version can be substituted for the other.&nbsp;&nbsp;Putting the DLL<br>
file into the same directory as the EXE file appears to guarantee that<br>the EXE picks it up.&nbsp;&nbsp;Static linking would avoid the problem entirely.<br><br>I just wish GHCi would link with the MSVC version of the freeglut DLL.
<br><br>What I really wish for, are pre-compiled versions of each piece that<br>work together and a fully automated installer that select all the<br>right versions of everything and put all the right pieces in all the<br>
right places.<br><br>The best part of all is this: I went through so much trouble trying to<br>get freeglut, Haskell-GLUT, and GHCi to play together and run some<br>examples, that once I finally got it working, I ended up deciding
<br>/not/ to look at graphics programming for a while.<br><br>-- Ron<br><br>_______________________________________________<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org
</a><br><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br></blockquote></div><br>