Re: [Haskell-cafe] HaXml and ghci unresolved symbol

Il Sat, Sep 09, 2006 at 05:20:55PM -0400, Mark T.B. Carroll ebbe a scrivere:
FWIW I have the same problem - I can't use HaXml with ghci. So it's not just you. (-:
Indeed! So I found my first bug in ghc... And now I'll dig into ghc bug reports to see if someone is working on the problem... This is going to be hard, but it's the way you start learning something....;-) Thanks for your kind attention. Below the full error messages with the code producing them. Andrea The code below works fine with Hugs: Main> :load xml.hs Main> main prova Main> If I try to compile it with ghc I get this: [11:16:06][andrea@laptop:~/devel/haskell/xml]$ ghc --make xml.hs -package HaXml -package hxml -o prova Chasing modules from: xml.hs Compiling Main ( xml.hs, xml.o ) Linking ... /usr/local/lib/hxml-0.2/lib/libhxml.a(HaXmlAdapter.o)(.text+0x12c1): In function `spZc_dflt': : undefined reference to `TextziXMLziHaXmlziPretty_zdwelement_infó /usr/local/lib/hxml-0.2/lib/libhxml.a(HaXmlAdapter.o)(.text+0x1435): In function `spZy_dflt': : undefined reference to `TextziXMLziHaXmlziPretty_zdwelement_infó /usr/local/lib/hxml-0.2/lib/libhxml.a(HaXmlAdapter.o)(.rodata+0xa4): undefined reference to `TextziXMLziHaXmlziPretty_zdwelement_closure` /usr/local/lib/hxml-0.2/lib/libhxml.a(HaXmlAdapter.o)(.rodata+0xc4): undefined reference to `TextziXMLziHaXmlziPretty_zdwelement_closure` collect2: ld returned 1 exit status Loading HaXml and hxml in ghci will produce: [11:15:39][andrea@laptop:~/devel/haskell/xml]$ ghci -package HaXml -package hxml ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | | GHC Interactive, version 6.4.2, for Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ \____/\/ /_/\____/|_| Type :? for help. Loading package base-1.0 ... linking ... done. Loading package Cabal-1.1.4 ... linking ... done. Loading package haskell98-1.0 ... linking ... done. Loading package haskell-src-1.0 ... linking ... done. Loading package HaXml-1.13.1 ... linking ... done. Loading package hxml-0.2 ... linking ... ghc-6.4.2: /usr/local/lib/hxml-0.2/lib/hxml.o: unknown symbol `TextziXMLziHaXmlziTypes_AttValue_con_info` ghc-6.4.2: unable to load package `hxml-0.2' This is the code: module Main where import Text.XML.HaXml import HaXmlAdapter -- from hxml xml = "<a>prova</a>" doc = xmlParse "tmp" xml getContent (Document prolog _ (Elem name _ content) _) = content cont = getContent doc showDoc :: [Content] -> IO () showDoc [] = return () showDoc (x:xs) = do putStrLn $ showContent x showDoc xs main = showDoc cont

It looks a bit like 'HaXml' has been updated after 'hxml' was built.
Try rebuilding 'hxml' against the 'HaXml' you've got installed.
On 9/10/06, Andrea Rossato
Il Sat, Sep 09, 2006 at 05:20:55PM -0400, Mark T.B. Carroll ebbe a scrivere:
FWIW I have the same problem - I can't use HaXml with ghci. So it's not just you. (-:
Indeed!
So I found my first bug in ghc... And now I'll dig into ghc bug reports to see if someone is working on the problem... This is going to be hard, but it's the way you start learning something....;-)
Thanks for your kind attention. Below the full error messages with the code producing them.
Andrea
The code below works fine with Hugs: Main> :load xml.hs Main> main prova
Main>
If I try to compile it with ghc I get this:
[11:16:06][andrea@laptop:~/devel/haskell/xml]$ ghc --make xml.hs -package HaXml -package hxml -o prova Chasing modules from: xml.hs Compiling Main ( xml.hs, xml.o ) Linking ... /usr/local/lib/hxml-0.2/lib/libhxml.a(HaXmlAdapter.o)(.text+0x12c1): In function `spZc_dflt': : undefined reference to `TextziXMLziHaXmlziPretty_zdwelement_infó /usr/local/lib/hxml-0.2/lib/libhxml.a(HaXmlAdapter.o)(.text+0x1435): In function `spZy_dflt': : undefined reference to `TextziXMLziHaXmlziPretty_zdwelement_infó /usr/local/lib/hxml-0.2/lib/libhxml.a(HaXmlAdapter.o)(.rodata+0xa4): undefined reference to `TextziXMLziHaXmlziPretty_zdwelement_closure` /usr/local/lib/hxml-0.2/lib/libhxml.a(HaXmlAdapter.o)(.rodata+0xc4): undefined reference to `TextziXMLziHaXmlziPretty_zdwelement_closure` collect2: ld returned 1 exit status
Loading HaXml and hxml in ghci will produce: [11:15:39][andrea@laptop:~/devel/haskell/xml]$ ghci -package HaXml -package hxml ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | | GHC Interactive, version 6.4.2, for Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ \____/\/ /_/\____/|_| Type :? for help.
Loading package base-1.0 ... linking ... done. Loading package Cabal-1.1.4 ... linking ... done. Loading package haskell98-1.0 ... linking ... done. Loading package haskell-src-1.0 ... linking ... done. Loading package HaXml-1.13.1 ... linking ... done. Loading package hxml-0.2 ... linking ... ghc-6.4.2: /usr/local/lib/hxml-0.2/lib/hxml.o: unknown symbol `TextziXMLziHaXmlziTypes_AttValue_con_info` ghc-6.4.2: unable to load package `hxml-0.2'
This is the code:
module Main where import Text.XML.HaXml import HaXmlAdapter -- from hxml
xml = "<a>prova</a>" doc = xmlParse "tmp" xml
getContent (Document prolog _ (Elem name _ content) _) = content
cont = getContent doc
showDoc :: [Content] -> IO () showDoc [] = return () showDoc (x:xs) = do putStrLn $ showContent x showDoc xs
main = showDoc cont _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Cheers, Lemmih

Il Sun, Sep 10, 2006 at 11:41:45AM +0200, Lemmih ebbe a scrivere:
It looks a bit like 'HaXml' has been updated after 'hxml' was built. Try rebuilding 'hxml' against the 'HaXml' you've got installed.
No, I installed the together, HaXml first and then hxml In hxml there where a couple of bugs, and no cabal file - AFAIK hxml is not maintained anymore - last release was done in 2002. I put everything in order and compiled it. Works fine in Hugs. Who knows, it could be just me. But! Look at this code, only pure HaXml. The output should be "a" and works with Hugs: module Main where import Text.XML.HaXml xml = "<a>prova</a>" doc = xmlParse "tmp" xml elemName (Document prolog _ (Elem name _ content) _) = name name = elemName doc main = putStrLn name And now: [12:03:27][andrea@laptop:~/devel/haskell/xml]$ ghc --make xml1.hs -package HaXml -o prova Chasing modules from: xml1.hs Compiling Main ( xml1.hs, xml1.o ) Linking ... [12:03:42][andrea@laptop:~/devel/haskell/xml]$ ./prova a [12:03:45][andrea@laptop:~/devel/haskell/xml]$ ghci -package HaXml xml1.hs [logo] Loading package base-1.0 ... linking ... done. Loading package haskell98-1.0 ... linking ... done. Loading package HaXml-1.13.1 ... linking ... done. Skipping Main ( xml1.hs, xml1.o ) Ok, modules loaded: Main. Prelude Main> main <interactive>: xml1.o: unknown symbol `TextziXMLziHaXmlziParse_xmlParse_closure' Prelude Main> :quit Leaving GHCi. This is just amazing for a Haskell newbie! Ciao Andrea

Andrea Rossato wrote:
[12:03:45][andrea@laptop:~/devel/haskell/xml]$ ghci -package HaXml xml1.hs [logo] Loading package base-1.0 ... linking ... done. Loading package haskell98-1.0 ... linking ... done. Loading package HaXml-1.13.1 ... linking ... done. Skipping Main ( xml1.hs, xml1.o ) Ok, modules loaded: Main. Prelude Main> main <interactive>: xml1.o: unknown symbol `TextziXMLziHaXmlziParse_xmlParse_closure'
Hrm, you're accessing a symbol presumably found in a library that isn't loaded. Either GHC cannot find the library, which shouldn't happen if you're using the right package switch, or the .hi file you compiled against is out of synch with the library, which also shouldn't happen, as both were compiled from the same source. - Did you compile and install HaXml from source? If not, was the binary meant for the version of GHC you're using? - Did you update anything after doing so? Some library, GHC itself, ...? - Did you use weird compiler switches (profiling on/off with missing profiling libraries)? - Did you move things around after compiling? Broken package database? configure --user with install --global or vice versa? - Did you install more than one version of HaXml? Or are remnants of failed installation attempts still in the search path? You could try the brute force approach of just exploding the source tree of HaXml right into your project directory and not using the installed package at all. ghc --make should be able to pick up the sources and compile them without further ado. For hxml this might actually be the right thing to do, because it's so small. However, if you didn't mess with the internals of some package, your problem is just weird. Udo. -- in the middle of a discussion about the "evil mangler" in GHC 5.04: <shapr> the evil mangler uses *perl* ?? <ChilliX> yes... <ChilliX> it is Evil after all

Il Sun, Sep 10, 2006 at 01:56:25PM +0200, Udo Stenzel ebbe a scrivere:
Hrm, you're accessing a symbol presumably found in a library that isn't loaded. Either GHC cannot find the library, which shouldn't happen if you're using the right package switch, or the .hi file you compiled against is out of synch with the library, which also shouldn't happen, as both were compiled from the same source.
- Did you compile and install HaXml from source? If not, was the binary meant for the version of GHC you're using?
I installed from source, compiling by myself.
- Did you update anything after doing so? Some library, GHC itself, ...?
No. Installed HaXml and tried it with this results.
- Did you use weird compiler switches (profiling on/off with missing profiling libraries)?
No. Just the HaXml default ones. Nothing weird as far as I can see.
- Did you move things around after compiling? Broken package database? configure --user with install --global or vice versa?
No. Also because that would result in ghc not compiling the code, I think. Instead, the code *gets* compiled by ghc, *but not* loaded by ghci: same code, obviously.
- Did you install more than one version of HaXml? Or are remnants of failed installation attempts still in the search path?
No, just version 1.13.1. No failed attempts whatsoever.
You could try the brute force approach of just exploding the source tree of HaXml right into your project directory and not using the installed package at all. ghc --make should be able to pick up the sources and compile them without further ado. For hxml this might actually be the right thing to do, because it's so small. However, if you didn't mess with the internals of some package, your problem is just weird.
I did not mess with anything. I believe my problem is weird, indeed. The solution you describe is feasible, but I'd like to get the general problem solved...;-) Andrea
participants (3)
-
Andrea Rossato
-
Lemmih
-
Udo Stenzel