
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.