Code::Blocks Forums
Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: byo on April 27, 2005, 04:01:00 pm
-
Hi, when I want to use TiXml inside my plugin but I;ve got following linker errors:
Info: resolving vtable for TiXmlDocumentby linking to __imp___ZTV13TiXmlDocument (auto-import)
.objs\wxsproject.o(.text$_ZN13TiXmlDocumentD1Ev[TiXmlDocument::~TiXmlDocument()]+0x3a): In function `ZSt24__uninitialized_copy_auxIN9__gnu_cxx17__normal_iteratorIP8wxStringSt6vectorIS2_SaIS2_EEEES7_ET0_T_S9_S8_12__false_type':
C:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ext/new_allocator.h: variable 'vtable for TiXmlDocument' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.
collect2: ld returned 1 exit status
After adding tixml.a into project I've got:
D:\CodeBlocks\cb_2_6\codeblocks\src\sdk\tinyxml\libtxml.a(tinyxml.o)(.text+0x136e): In function `ZNK9TiXmlNode18NextSiblingElementEv':
D:/CodeBlocks/cb_2_6/codeblocks/src/sdk/tinyxml/tinyxml.cpp:410: multiple definition of `TiXmlNode::NextSiblingElement() const'
D:\CodeBlocks\cb_2_6\codeblocks\src\devel/libcodeblocks.a(d002332.o)(.text+0x0): first defined here
D:\CodeBlocks\cb_2_6\codeblocks\src\sdk\tinyxml\libtxml.a(tinyxml.o)(.text+0x256a): In function `ZN13TiXmlDocumentC1EPKc':
D:/CodeBlocks/cb_2_6/codeblocks/src/sdk/tinyxml/tinyxml.cpp:670: multiple definition of `TiXmlDocument::TiXmlDocument(char const*)'
D:\CodeBlocks\cb_2_6\codeblocks\src\devel/libcodeblocks.a(d000675.o)(.text+0x0): first defined here
D:\CodeBlocks\cb_2_6\codeblocks\src\sdk\tinyxml\libtxml.a(tinyxml.o)(.text+0x2678): In function `ZN13TiXmlDocument8LoadFileEv':
D:/CodeBlocks/cb_2_6/codeblocks/src/sdk/tinyxml/tinyxml.cpp:678: multiple definition of `TiXmlDocument::LoadFile()'
D:\CodeBlocks\cb_2_6\codeblocks\src\devel/libcodeblocks.a(d000673.o)(.text+0x0): first defined here
D:\CodeBlocks\cb_2_6\codeblocks\src\sdk\tinyxml\libtxml.a(tinyxml.o)(.text+0x12b4): In function `ZNK9TiXmlNode17FirstChildElementEv':
D:/CodeBlocks/cb_2_6/codeblocks/src/sdk/tinyxml/tinyxml.cpp:381: multiple definition of `TiXmlNode::FirstChildElement() const'
D:\CodeBlocks\cb_2_6\codeblocks\src\devel/libcodeblocks.a(d002330.o)(.text+0x0): first defined here
D:\CodeBlocks\cb_2_6\codeblocks\src\sdk\tinyxml\libtxml.a(tinyxml.o)(.text+0x4c4): In function `ZN9TiXmlNodeD2Ev':
D:/CodeBlocks/cb_2_6/codeblocks/src/sdk/tinyxml/tinyxml.cpp:140: multiple definition of `TiXmlNode::~TiXmlNode()'
D:\CodeBlocks\cb_2_6\codeblocks\src\devel/libcodeblocks.a(d001903.o)(.text+0x0): first defined here
collect2: ld returned 1 exit status
I guess that TiXml has been linked into codeblocks library. But how can I use this ? (I got MinGW 3.2 with Msys 1.0.10)
-
You might try reading the C::B code and copy some of the code used. Maybe it got some defines or DLLIMPORT definitions in there.
-
Hmm, I'm using TiXml directly from C::B sdk, maybe there's something missing. I will try to find the solution (just need to find some free time :? ).
Maybe if someone has solved this yet and would be able to help me. I would appreciate that :D
-
I've found the solution for this problem :D.
TiXml classes should be compiled with DLLIMPORT (I've made it by including "../settings.h" file, adding DLLIMPORT for each class in main headers and also copying all compiler definitions from sdk to TiXml target).
It's working but with modified version of TiXml. But I think it shuoldn't be a big problem - only few lines of code need modification.
-
Try this instead of changing the code:
1. Add "txml" to the library list and place it before the codeblocks library.
2. Add the "txml" dir (...\sdk\tinyxml) to the library dirs (I placed it first, but don't think it matters).
For some reason, when the make for the SDK DLL creates the static lib ("Create static library too" is checked), it doesn't link in libtxml.a in its original form. Any ideas?
-
This error has already been fixed ans all needed should be inside CVS :). It works fine with default .cbp project, wx 2.6 has missing compiler dedfines for TiXml target but these can be easily taken from default project. After this change You have timl library just insided codeblocks.dll ready to use outside :)
-
Yeah, I just got it and recompiled everything wx2.6.0. The static lib seems to link with wxSmith just fine.
-
This is causing a problem. We use tinyxml in a wxsmith control plugin. The problem is that the compiler complains of multiple definitions of tinyxml references. The reason is that both codeblocks.dll and wxsmithlib.dll bind to tinyxml static libraries. I have found that, removing txml static library from the wxsmith project then compiling it (and wxsmith contrib) wxsmith compiles and works fine. This then allows us to link to both wxsmithlib.dll and codeblocks.dll without the errors. The problem became evident when we started to use tinyxpath (which we include the source in our project but exclude tinyxml source). However, we believe the problem was also present less obviously in that different modules were using the different calls to pass data and failing.
May I suggest that we lose the linking to txml static library in wxsmith?
We are using codeblocks 8.04 release and same source code.