Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  Problems linking code from the book Haskell      School of
      Expression (Philippe Sismondi)
   2. Re:  Problems linking code from the book Haskell School of
      Expression (Brandon Allbery)
   3. Re:  Problems linking code from the book Haskell  School of
      Expression (Philippe Sismondi)
   4. Re:  Problems linking code from the book Haskell School of
      Expression (Brandon Allbery)
   5. Re:  Problems linking code from the book Haskell  School of
      Expression (Philippe Sismondi)


----------------------------------------------------------------------

Message: 1
Date: Fri, 25 Nov 2011 12:16:19 -0500
From: Philippe Sismondi <[email protected]>
Subject: [Haskell-beginners] Problems linking code from the book
        Haskell School of Expression
To: Beginners Haskell <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

Greetings. Yesterday I decided to try some of the code in Paul Hudak's book The 
Haskell School of Expression. 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.

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.

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:

   cairo-0.12.2
   gio-0.12.2
   glib-0.12.2
   gtk-0.12.2
   pango-0.12.2
   soegtk-0.12.1

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.)

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)

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:

module Main where

import Graphics.SOE.Gtk

main =
    runGraphics (
    do w <- openWindow "SOE First Try" (300,300)
       drawInWindow w (text (100,100) "Hello Graphics World")
       k <- getKey w
       closeWindow w
    )
 
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. 

Then, the link eventually fails because of a huge number of unresolved symbols. 
Here is a sample link error from the verbose output:

Undefined symbols for architecture i386:
  "_cairo_arc", referenced from:
      _sbnE_info in libHSsoegtk-0.12.1.a(Gtk.o)
      _se2n_info in libHSsoegtk-0.12.1.a(Gtk.o)
      _sf5B_info in libHSsoegtk-0.12.1.a(Gtk.o)
      _svSr_info in libHScairo-0.12.2.a(Paths.o)
      _swiH_info in libHScairo-0.12.2.a(Paths.o)
  "_cairo_arc_negative", referenced from:
      _seqb_info in libHSsoegtk-0.12.1.a(Gtk.o)
      _svPR_info in libHScairo-0.12.2.a(Paths.o)
      _swg7_info in libHScairo-0.12.2.a(Paths.o)

and on and on.

I have no idea what is happening here.

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.

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:

/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 -L/opt/local/lib 
-L/Users/Philippe/Library/Haskell/ghc-7.0.3/lib/pango-0.12.2/lib 

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. 

So is it normal for ghc to link against /opt/local/lib libraries, or is it 
something in my environment that is triggering this?

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)?

Any help is appreciated.

- Phil -


-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20111125/38282355/attachment-0001.htm>

------------------------------

Message: 2
Date: Fri, 25 Nov 2011 13:28:21 -0500
From: Brandon Allbery <[email protected]>
Subject: Re: [Haskell-beginners] Problems linking code from the book
        Haskell School of Expression
To: Philippe Sismondi <[email protected]>
Cc: Beginners Haskell <[email protected]>
Message-ID:
        <CAKFCL4UrKFj0V092dsqozvOUcU2wNb=2mmd_hhecdawkh0i...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Fri, Nov 25, 2011 at 12:16, Philippe Sismondi <[email protected]>wrote:

> 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)
>

Was the MacPorts gtk2 port built +universal?  ("port installed gtk2", see
if what it prints includes "+universal".)  SL on most modern Macs builds
64-bit by default, whereas the ghc stuff in MacPorts is 32-bit only.

-- 
brandon s allbery                                      [email protected]
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20111125/73e974d3/attachment-0001.htm>

------------------------------

Message: 3
Date: Fri, 25 Nov 2011 14:08:41 -0500
From: Philippe Sismondi <[email protected]>
Subject: Re: [Haskell-beginners] Problems linking code from the book
        Haskell School of Expression
To: Beginners Haskell <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"


On 2011-11-25, at 1:28 PM, Brandon Allbery wrote:

> On Fri, Nov 25, 2011 at 12:16, Philippe Sismondi <[email protected]> wrote:
> 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)
> 
> Was the MacPorts gtk2 port built +universal?  ("port installed gtk2", see if 
> what it prints includes "+universal".)  SL on most modern Macs builds 64-bit 
> by default, whereas the ghc stuff in MacPorts is 32-bit only.

I guess I did not supply enough info.

I don't see why the architecture of macports stuff would make a difference. I 
should perhaps have said in the original post that I have no macports haskell 
software installed. I am not using the macports haskell-platform port. I am 
using the OS X Haskell Platform package downloaded from the web: Haskell 
Platform 2011.2.0.1-i386.pkg. To answer your question, though, here is the gtk2 
macports info:

> port installed gtk2
The following ports are currently installed:
  gtk2 @2.24.4_0+x11
  gtk2 @2.24.8_1+x11 (active)

Why is ghc linking against anything installed by macports, i.e. libs in 
/opt/local/lib? Why would the flag -L/opt/local/lib be in the link step of ghc 
--make? Is this usual for ghc, or is it more likely something in my setup?

Here are the library directories installed in ~/Library/Haskell/ghc-7.0.3/lib. 
Shouldn't ghc just link against these?

cairo-0.12.2
gio-0.12.2
glib-0.12.2
gtk-0.12.2
gtk2hs-buildtools-0.12.1
pango-0.12.2
soegtk-0.12.1


> 
> -- 
> brandon s allbery                                      [email protected]
> wandering unix systems administrator (available)     (412) 475-9364 vm/sms
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20111125/2cdf81fa/attachment-0001.htm>

------------------------------

Message: 4
Date: Fri, 25 Nov 2011 14:29:11 -0500
From: Brandon Allbery <[email protected]>
Subject: Re: [Haskell-beginners] Problems linking code from the book
        Haskell School of Expression
To: Philippe Sismondi <[email protected]>
Cc: Beginners Haskell <[email protected]>
Message-ID:
        <cakfcl4vl_iyquo3qp5bvsyubqq6rf9vcdyasaffipm1bnvk...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Fri, Nov 25, 2011 at 14:08, Philippe Sismondi <[email protected]>wrote:

> I don't see why the architecture of macports stuff would make a
> difference. I should perhaps have said in the original post that I have no
> macports haskell software installed. I am not using the macports
> haskell-platform port. I am using the OS X Haskell Platform package
> downloaded from the web: Haskell Platform 2011.2.0.1-i386.pkg. To answer
> your question, though, here is the gtk2 macports info:
>

So, where did you get the gtk2hs stuff then?  Your SOE is clearly the
gtk2hs version, and gtk2hs was evidently built against MacPorts.

-- 
brandon s allbery                                      [email protected]
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20111125/f65485df/attachment-0001.htm>

------------------------------

Message: 5
Date: Fri, 25 Nov 2011 15:33:36 -0500
From: Philippe Sismondi <[email protected]>
Subject: Re: [Haskell-beginners] Problems linking code from the book
        Haskell School of Expression
To: Beginners Haskell <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"


On 2011-11-25, at 2:29 PM, Brandon Allbery wrote:

> On Fri, Nov 25, 2011 at 14:08, Philippe Sismondi <[email protected]> wrote:
> I don't see why the architecture of macports stuff would make a difference. I 
> should perhaps have said in the original post that I have no macports haskell 
> software installed. I am not using the macports haskell-platform port. I am 
> using the OS X Haskell Platform package downloaded from the web: Haskell 
> Platform 2011.2.0.1-i386.pkg. To answer your question, though, here is the 
> gtk2 macports info:
> 
> So, where did you get the gtk2hs stuff then?  Your SOE is clearly the gtk2hs 
> version, and gtk2hs was evidently built against MacPorts.
> 

I got everything using cabal-install. It did not work smoothly at first. I did:

        cabal install soegtk

but this reported errors and suggested that I must first do

        cabal install gtk2hs-buildtools

I did this. The above delivered some utility executables. I made these 
available on my PATH, and then did

        cabal install soegtk

Your suggestion reminds me that installing soegtk caused an outpouring of 
messages about "ignoring libraries". So the problem may well have arisen at 
that point. I should probably look at the cabal packages for gtk2hs, or maybe 
contact the guys who put it together.

Actually, it is high time that I bite the bullet and learn about cabal 
internals anyway. I just HATE that kind of thing. I can hardly estimate the 
amount of time I have spent fighting with package management and library stuff 
in Common Lisp and other languages that live in a less than robust online 
echosystem.

Thanks for your help. I'll dig into the cabal side of gtk2hs.

- Phil -

> -- 
> brandon s allbery                                      [email protected]
> wandering unix systems administrator (available)     (412) 475-9364 vm/sms
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20111125/ea67466e/attachment.htm>

------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 41, Issue 37
*****************************************

Reply via email to