HaXml and ghci unresolved symbol

Hello! probably it's me, but I cannot understand what I'm doing wrong. I'm trying to learn HaXml. I've never used it before and I never did xml processing in Haskell. So I'm a total newbie!! I downloaded and compiled. Everything seems fine. I'm also able to run some examples in the related directory of the source tree. Then I try doing something myself. Very simply, a document with just one element: module Xml where import Text.XML.HaXml xml = "<a>test</a>" doc = xmlParse "test" xml elemName (Document prolog _ (Elem name _ _) _) = name When I try it: *Xml> elemName doc I get a message I've never got before (I'm a newbie!) and I don't know whether the problem is in my code (this would be my first guess), in HaXml or in GHCi. And so I cannot even start understanding out to solve it: During interactive linking, GHCi couldn't find the following symbol: TextziXMLziHaXmlziParse_xmlParse_closure This may be due to you not asking GHCi to load extra object files, archives or DLLs needed by your current session. Restart GHCi, specifying the missing library using the -L/path/to/object/dir and -lmissinglibname flags, or simply by naming the relevant files on the GHCi command line. Alternatively, this link failure might indicate a bug in GHCi. If you suspect the latter, please send a bug report to: glasgow-haskell-bugs@haskell.org *Xml> xmlParse is defined in Text.Xml.HaXml (xmlParse :: String -> String -> Document) and it should be imported by Text.XML.HaXml. Can you give me please some directions? Thanks for your kind attention.

Hello Andrea, Saturday, September 9, 2006, 4:17:36 PM, you wrote:
During interactive linking, GHCi couldn't find the following symbol: TextziXMLziHaXmlziParse_xmlParse_closure
as a workaround, you can try to run your program using runghc and compile it using "ghc --make" -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

On 9/9/06, Andrea Rossato
Hello! [snip] During interactive linking, GHCi couldn't find the following symbol: TextziXMLziHaXmlziParse_xmlParse_closure This may be due to you not asking GHCi to load extra object files, archives or DLLs needed by your current session. Restart GHCi, specifying the missing library using the -L/path/to/object/dir and -lmissinglibname flags, or simply by naming the relevant files on the GHCi command line. Alternatively, this link failure might indicate a bug in GHCi. If you suspect the latter, please send a bug report to: glasgow-haskell-bugs@haskell.org *Xml>
Maybe "...use -package HaXml interactively with GHCi..." (That's from the HaXml website.) So try it with ghci -package HaXml Xml.hs? HTH, Jason

Il Sat, Sep 09, 2006 at 09:58:03AM -0700, Jason Dagit ebbe a scrivere:
Maybe "...use -package HaXml interactively with GHCi..." (That's from the HaXml website.)
I'm using "-package HaXml", obviously, otherwise the module would not load. What I do not understand is that "unresolved symbol" message: I would expect some type error message, or some other kind of error... The HaXml library has been correctly installed, as far as I know: I can compile and run some examples. I'm facing a similar problem when linking hxml to HaXml: I'd like to use the HaXmlAdapter module of hxml, but I keep getting a similar "unresolved symbol" message. Message that I'm not able to understand: when it comes to c or c++ code I know I can run ldd, or I can chase a missing library. I don't know what to do with ghc. :-( Thanks for your kind attention. Andrea

Il Sat, Sep 09, 2006 at 02:17:36PM +0200, Andrea Rossato ebbe a scrivere:
probably it's me, but I cannot understand what I'm doing wrong.
Thanks to the discussion of this thread I was able to (sort of) isolate the problem and understand why I cannot get hxml (if linked with HaXml) to work with ghci. It seems related to dynamic linking: I created a separated module (Xml.hs) that imports Text.XML.HaXml and parses a xml string. I then created a file (xml.hs) that imports Xml and prints "name", defined in Xml.hs. The expected output should be "elementTest". Now: if I compile Xml.hs alone it compiles without warnings or errors. But when I try to load Xml.o with ghci I get an "unresolved symbol" error. If I load in ghci the file xml.hs (that imports Xml.hs), it loads fine, but when I try to evaluate "main" I get the same "unresolved symbol" error. If I compile xml.hs, statically linking it to Xml.hs, I get a perfectly working "a.out" that runs as expected. So, I'm not able to create an object file (dynamically) linked to HaXml. This is the reason why hxml doesn't work with ghc (and ghci) but works perfectly with hugs. hxml works fine if I do not link it to HaXml (that is to say, without using the HaXmlAdapter module). Now, I don't know whether I should contact the HaXml author or submit a bug report to the ghc developers wiki. Can you please help me with this point? And, if you happen to have a second and HaXml installed, can you reproduce my problem? Thank you very much for your kind attention. Below the code with the output of my attempts. Sorry for such a long message. Ciao Andrea Xml.hs: ----------- module Xml where import Text.XML.HaXml xml = "<elementTest>This is a test</elementTest>" doc = xmlParse "tmp" xml elemName (Document prolog _ (Elem name _ content) _) = name name = elemName doc ------------ xml.hs: ----------- module Main where import Xml main = putStrLn name --------- Results: ======== $ ghc --make -package HaXml Xml.hs Chasing modules from: Xml.hs Compiling Xml ( Xml.hs, Xml.o ) $ ghci -package HaXml Xml.o [logo] Loading package base-1.0 ... linking ... done. Loading package haskell98-1.0 ... linking ... done. Loading package HaXml-1.13.1 ... linking ... done. Loading object (static) Xml.o ... done final link ... ghc-6.4.2: Xml.o: unknown symbol `TextziXMLziHaXmlziParse_xmlParse_closure' ghc-6.4.2: linking extra libraries/objects failed $ ghci -package HaXml xml.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 Xml ( ./Xml.hs, ./Xml.o ) Compiling Main ( xml.hs, interpreted ) Ok, modules loaded: Main, Xml. *Main> main <interactive>: ./Xml.o: unknown symbol `TextziXMLziHaXmlziParse_xmlParse_closure' *Main> :quit Leaving GHCi. $ ghc --make -package HaXml xml.hs Chasing modules from: xml.hs Skipping Xml ( ./Xml.hs, ./Xml.o ) Compiling Main ( xml.hs, xml.o ) Linking ... $ ./a.out elementTest $ ghci -package HaXml /usr/lib/ghc-6.4.2/HSHaXml.o [logo] Loading package base-1.0 ... linking ... done. Loading package haskell98-1.0 ... linking ... done. Loading package HaXml-1.13.1 ... linking ... done. Loading object (static) /usr/lib/ghc-6.4.2/HSHaXml.o ... done final link ... done Prelude> :quit Leaving GHCi.

Andrea Rossato wrote:
It seems related to dynamic linking: I created a separated module (Xml.hs) that imports Text.XML.HaXml and parses a xml string. I then created a file (xml.hs) that imports Xml and prints "name", defined in Xml.hs. The expected output should be "elementTest".
Whatever it is, I cannot reproduce any of your problems. I installed HaXml-1.13.2 from source using Cabal, and both "ghc -c Xml.hs" and "ghc --make xml.hs" work as expected, even without the -package switch. This is GHC 6.4.1 on Linux.
If I load in ghci the file xml.hs (that imports Xml.hs)
Could it be that you're on Windows, which cannot keep xml.hs and Xml.hs apart? -Udo -- Eagles may soar but weasels don't get sucked into jet engines. -- Steven Wright

Il Mon, Sep 11, 2006 at 11:30:41AM +0200, Udo Stenzel ebbe a scrivere:
Whatever it is, I cannot reproduce any of your problems. I installed HaXml-1.13.2 from source using Cabal, and both "ghc -c Xml.hs" and "ghc --make xml.hs" work as expected, even without the -package switch. This is GHC 6.4.1 on Linux.
"I installed HaXml-1.13.2 from source using Cabal" ... Instead I did not!! I followed the instruction on the HaXml web site: ./configure; make; make install... I'm using Linux too. So, first I installed a fresh ghc-6.4.1 and got the same problem. Than I tried installing HaXml using just Cabal: runhaskell Setup.hs configure|build|install and... HaXml started working fine! I went back to ghc-6.4.2 and did the same, with Cabal. And it works perfectly! I don't know what to say... Well, I do know, in fact: first, thank you all, thank you so much for you kind patience and the time you spent to help me. Second, never trust developers' instruction on how to install their software...;-) Thank you once again! Andrea ps: needless to say, even hxml works perfectly now!

Andrea Rossato
So, I'm not able to create an object file (dynamically) linked to HaXml. This is the reason why hxml doesn't work with ghc (and ghci) but works perfectly with hugs.
Now, I don't know whether I should contact the HaXml author or submit a bug report to the ghc developers wiki.
I think this must be a bug in ghci, introduced between 6.4.1 and 6.4.2. I tried your example using HaXml-1.15 and ghc-6.4.1, and could not reproduce the behaviour. Everything worked just fine for me, both interpreted and compiled. Regards, Malcolm
participants (5)
-
Andrea Rossato
-
Bulat Ziganshin
-
Jason Dagit
-
Malcolm Wallace
-
Udo Stenzel