Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

XML import issue

Moderators: kris

Posted: 02/18/09 23:29:30

Completed my xml loader for one file and now when I went to do the next I get this when compiling:

dsss_objs/D/gfx.texture.o:(.rodata+0x250): multiple definition of `_D5tango4text3xml8Document15T8DocumentTaZ8Document7Visitor6initZ' dsss_objs/D/pGUI.guiContext.o:(.rodata+0x248): first defined here dsss_objs/D/gfx.texture.o:(.rodata+0x2b0): multiple definition of `_D5tango4text3xml8Document15T8DocumentTaZ8Document8NodeImpl6initZ' dsss_objs/D/pGUI.guiContext.o:(.rodata+0x2a0): first defined here dsss_objs/D/gfx.texture.o:(.rodata+0x2fc): multiple definition of `_D5tango4text3xml8Document14T7XmlPathTaZ7XmlPath7NodeSet6initZ' dsss_objs/D/pGUI.guiContext.o:(.rodata+0x2ec): first defined here

Just doing the standard import tango.text.xml.Document;

Using dsss build / rebuild to build my projects... Anyone know a way to fix?

Author Message

Posted: 02/19/09 06:15:05

Ok, i figured out what is causing this, but I am not sure how to get around it as I don't have much experience with templates.

In file a, in the function I am using to grab my data from an xml file, I declare: auto doc = new Document!(char);

In another file, i have a function that gets it's data from an xml file and do the same declaration: auto doc = new Document!(char);

module File1;
Some_Function()
{
//some stuff
auto doc = Document!(char);
//some stuff
}

module File2;
import File1;

Some_Other_Function()
{
//do some stuff
auto doc = new Document!(char);
//do some stuff
}

This causes those errors to pop up, even though the 2 Document!(char) objects are never in existence at the same time. Is there something here I am missing? I think I can bypass all this buy defining a global Document!(char) and externing it places, but not sure...

Anyone have ideas?

Posted: 02/19/09 07:01:13

That's really awful. I know some versions of the compiler have had issues with templates before, but haven't seen that for a while. Which compiler (and version) are you using?

Posted: 02/19/09 07:24:01 -- Modified: 02/19/09 07:25:50 by
wolftousen

I just uninstalled everything and am going to try a fresh install.

I just uninstall all the deb packages I had installed to get tango/dmd/dsss and will try to build manually I guess.

Posted: 02/19/09 09:23:09

FWIW, this is probably an artifact from how DSSS works (or works by default at least), but the D compilers have indeed had such problems in the past (and I'm not convinced that all kinks are removed yet).

A possible workaround is to make an alias of the template instantiation, and then you use that instead in the various files.

alias Document!(char) MyDocument;

Posted: 02/19/09 18:49:49

I made a quick work around for now, using 2 functions, that take in a function or delegate arguement, load in the file and parse it then send the Document object to the fucntion or delegate.

When i reinstalled everything I noticed that the .deb package for dmd installs 1.037. I had noticed something about above 1.033 not being supported so download it form the tango site and replaced my install, but still have the same issues when i'm not using my work around. What version do you recommend using?

Posted: 03/21/09 13:52:38 -- Modified: 03/21/09 13:55:50 by
tomni -- Modified 3 Times

There was another thread before about this issue

http://www.dsource.org/projects/tango/forums/topic/555

It's definitely not related to "linking libtango-user-dmd.a into your build as well as dsss linking in objects". I removed all default imports and just used DSSS. Still the same problem. Furthermore its not related to any specific D or Tango Version. I tested with various combinations. Any thoughts how to solve this issue?

Posted: 03/21/09 14:11:31

Hmm, an

alias Document!(char) MyDocument;

in a file that is imported where it is used may help, if not then this appears to be a compiler bug.

Posted: 03/22/09 14:12:45

How can we proceed to fix this? Where to post this DMD bug report?

Posted: 03/22/09 14:52:48

To report it, it needs to be boiled down to a minimal example (one that doesn't depend on anything like Tango or other libraries), and does nothing more than exhibit the issue.

Then post it to http://d.puremagic.com/issues/

Posted: 03/22/09 15:33:45

OK, Ill gonna submit it as soon as I find some time to boil it down. Thx Tom