<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Greetings. Yesterday I decided to try some of the code in Paul Hudak's book <i>The Haskell School of Expression</i>. I am having problems when I do ghc --make of the code on page 40 of the book, which is the first graphics program therein.<div><br></div><div>I am running OS X Snow Leopard, with the Haskell Platform (32 bit), ghc version 7.0.3. I am very green when it comes to looking under the covers at what gcc, ld, etc do at the behest of ghc. This is where things seem to go wrong, as I outline below.<br><div><br></div><div>In setting up to try this code I discovered that I needed to install the package soegtk to get Graphics.SOE.Gtk. The cabal install of soegtk was not smooth: it appears to me that cabal does not always handle dependencies as one would hope. However, I eventually got soegtk and the packages upon which it depends installed. Here is my list of local user packages as reported by ghc-pkg:</div><div><br></div><div><div>&nbsp; &nbsp;cairo-0.12.2</div><div>&nbsp; &nbsp;gio-0.12.2</div><div>&nbsp; &nbsp;glib-0.12.2</div><div>&nbsp; &nbsp;gtk-0.12.2</div><div>&nbsp; &nbsp;pango-0.12.2</div><div>&nbsp; &nbsp;soegtk-0.12.1</div></div><div><br></div><div>Oddly, in the course of running cabal install to get the above packages, at some point I got a flurry of messages similar to the one below. (This is not one of the actual messages from cabal install; I did not keep those. This warning message is from the ghc --make step, as described below.)</div><div><br></div><div><font class="Apple-style-span" color="#8f1792">ld: warning: ignoring file /opt/local/lib/libgtk-x11-2.0.dylib, file was built for unsupported file format which is not the architecture being linked (i386)</font></div><div><br></div><div>This puzzled me, and the same thing came up at a later stage, as I shall describe shortly. But initially I ignored the messages and proceeded to try to make my sample program. Here is the code from Hudak's book, which I put in Main.hs:</div><div><font class="Apple-style-span" color="#8f1792"><br></font></div><div><div><font class="Apple-style-span" color="#8f1792">module Main where</font></div><div><font class="Apple-style-span" color="#8f1792"><br></font></div><div><font class="Apple-style-span" color="#8f1792">import Graphics.SOE.Gtk</font></div><div><font class="Apple-style-span" color="#8f1792"><br></font></div><div><font class="Apple-style-span" color="#8f1792">main =</font></div><div><font class="Apple-style-span" color="#8f1792">&nbsp; &nbsp; runGraphics (</font></div><div><font class="Apple-style-span" color="#8f1792">&nbsp; &nbsp; do w &lt;- openWindow "SOE First Try" (300,300)</font></div><div><font class="Apple-style-span" color="#8f1792">&nbsp; &nbsp; &nbsp; &nbsp;drawInWindow w (text (100,100) "Hello Graphics World")</font></div><div><font class="Apple-style-span" color="#8f1792">&nbsp; &nbsp; &nbsp; &nbsp;k &lt;- getKey w</font></div><div><font class="Apple-style-span" color="#8f1792">&nbsp; &nbsp; &nbsp; &nbsp;closeWindow w</font></div><div><font class="Apple-style-span" color="#8f1792">&nbsp; &nbsp; )</font></div><div>&nbsp;</div></div><div>When I do ghc --make Main, it grinds forever at the link stage. The link fails. It also gives ld warnings about ignoring libraries in /opt/local/lib, as in the example above.&nbsp;</div><div><br></div><div>Then, the link eventually fails because of a huge number of unresolved symbols. Here is a sample link error from the verbose output:</div><div><br></div><div><div><font class="Apple-style-span" color="#8f1792">Undefined symbols for architecture i386:</font></div><div><font class="Apple-style-span" color="#8f1792">&nbsp; "_cairo_arc", referenced from:</font></div><div><font class="Apple-style-span" color="#8f1792">&nbsp; &nbsp; &nbsp; _sbnE_info in libHSsoegtk-0.12.1.a(Gtk.o)</font></div><div><font class="Apple-style-span" color="#8f1792">&nbsp; &nbsp; &nbsp; _se2n_info in libHSsoegtk-0.12.1.a(Gtk.o)</font></div><div><font class="Apple-style-span" color="#8f1792">&nbsp; &nbsp; &nbsp; _sf5B_info in libHSsoegtk-0.12.1.a(Gtk.o)</font></div><div><font class="Apple-style-span" color="#8f1792">&nbsp; &nbsp; &nbsp; _svSr_info in libHScairo-0.12.2.a(Paths.o)</font></div><div><font class="Apple-style-span" color="#8f1792">&nbsp; &nbsp; &nbsp; _swiH_info in libHScairo-0.12.2.a(Paths.o)</font></div><div><font class="Apple-style-span" color="#8f1792">&nbsp; "_cairo_arc_negative", referenced from:</font></div><div><font class="Apple-style-span" color="#8f1792">&nbsp; &nbsp; &nbsp; _seqb_info in libHSsoegtk-0.12.1.a(Gtk.o)</font></div><div><font class="Apple-style-span" color="#8f1792">&nbsp; &nbsp; &nbsp; _svPR_info in libHScairo-0.12.2.a(Paths.o)</font></div><div><font class="Apple-style-span" color="#8f1792">&nbsp; &nbsp; &nbsp; _swg7_info in libHScairo-0.12.2.a(Paths.o)</font></div></div><div><br></div><div>and on and on.</div><div><br></div><div>I have no idea what is happening here.</div><div><br></div><div>First, I don't know whether the linker messages about ignoring libs in /opt/local/lib is connected with the unresolved symbols, but one would suspect that it is.</div><div><br></div><div>Second, it is not clear to me why ghc would link against anything in /opt/local/lib, which it clearly does. Here are the first couple of lines of verbose output from ghc --make, showing the inclusion of the flag -L/opt/local/lib:</div><div><br></div><div><font class="Apple-style-span" color="#8f1792">/Developer/usr/bin/gcc -v -o Main -march=i686 -m32 -fno-stack-protector -DDONT_WANT_WIN32_DLL_SUPPORT Main.o -L/Users/Philippe/Library/Haskell/ghc-7.0.3/lib/soegtk-0.12.1/lib -L/Library/Haskell/ghc-7.0.3/lib/stm-2.2.0.1/lib -L/Users/Philippe/Library/Haskell/ghc-7.0.3/lib/gtk-0.12.2/lib </font><font class="Apple-style-span" color="#1818ff">-L/opt/local/lib</font><font class="Apple-style-span" color="#8f1792"> -L/Users/Philippe/Library/Haskell/ghc-7.0.3/lib/pango-0.12.2/lib&nbsp;</font></div><div><br></div><div>I have plenty of macports stuff installed in /opt/local. But I have not intentionally included /opt/local/lib in any path. That is, I do NOT have, for example, LD_LIBRARY_PATH or DYLD_LIBRARY_PATH set.&nbsp;</div></div><div><br></div><div>So is it normal for ghc to link against /opt/local/lib libraries, or is it something in my environment that is triggering this?</div><div><br></div><div>And, in any case, is that why the link fails? What about the references to "architecture i386"? Do they provide the necessary clue for the clueless (me)?</div><div><br></div><div>Any help is appreciated.</div><div><br></div><div>- Phil -</div><div><br></div><div><br></div></body></html>