Author Topic: TiXmlText causes auto-import linker errors  (Read 5256 times)

Offline artoj

  • Almost regular
  • **
  • Posts: 206
  • Location: Supporting my team
    • http://ajonsson.kapsi.fi/
TiXmlText causes auto-import linker errors
« on: August 09, 2006, 08:12:21 pm »
Hello,

I'm using TiXmlText class (from TinyXML in C::B SDK) in my Code Snippets plugin but I've have problem with the linker creating auto-import errors. Using the TiXmlElement class for example does not create these errors.

A simple way to reproduce is to create new Code::Blocks plugin, include "<tinyxml/tinyxml.h>" and use the TiXmlText class somewhere.

The log:

Code: [Select]
mingw32-g++.exe -DBUILDING_PLUGIN -DHAVE_W32API_H -D__WXMSW__ -DWXUSINGDLL -DTIXML_USE_STL -DcbDEBUG -DCB_PRECOMP -DWX_PRECOMP -DwxUSE_UNICODE -pipe -mthreads -fmessage-length=0 -fexceptions -Winvalid-pch -g  -IC:\SVN\codeblocks\src\sdk -IC:\SVN\codeblocks\src\sdk\wxscintilla\include -IC:\wxWidgets-2.6.3\include -IC:\wxWidgets-2.6.3\lib\gcc_dll\mswu -IC:\MinGW\include  -c TestPlugin.cpp -o obj\Debug\TestPlugin.o
mingw32-g++.exe -shared   -Wl,--dll -LC:\SVN\codeblocks\src\devel -LC:\wxWidgets-2.6.3\lib\gcc_dll -LC:\MinGW\lib  obj\Debug\TestPlugin.o   -o .\TestPlugin.dll  -lcodeblocks -lwxmsw26u

Info: resolving vtable for TiXmlTextby linking to __imp___ZTV9TiXmlText (auto-import)
obj\Debug\TestPlugin.o(.text$_ZN9TiXmlTextD1Ev[TiXmlText::~TiXmlText()]+0xb): In function `ZNSt6vectorIPN14BlockAllocatorI21CodeBlocksLayoutEventLj75ELb0EE11LinkedBlockIS1_EESaIS5_EEixEj':
C:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_vector.h: variable 'vtable for TiXmlText' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.

obj\Debug\TestPlugin.o(.text$_ZN9TiXmlTextC1EPKc[TiXmlText::TiXmlText(char const*)]+0x54):C:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_vector.h: variable 'vtable for TiXmlText' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.

collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
0 errors, 0 warnings

I'm using Windows XP x64 and mingw 5.0.3 (gcc 3.4.2) and the latest SVN version of Code::Blocks.

I can't reproduce it with Ubuntu Linux (Dapper), GCC 4.0.3, C::B revision 2820.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: TiXmlText causes auto-import linker errors
« Reply #1 on: August 09, 2006, 08:41:59 pm »
Funny, you should not auto-import anything at all from TinyXML. Do you not have import libs?
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline artoj

  • Almost regular
  • **
  • Posts: 206
  • Location: Supporting my team
    • http://ajonsson.kapsi.fi/
Re: TiXmlText causes auto-import linker errors
« Reply #2 on: August 09, 2006, 09:37:30 pm »
Funny, you should not auto-import anything at all from TinyXML. Do you not have import libs?

I link to libcodeblocks.a in the devel directory of Code::Blocks' source directory. The lib is built from revision 2831.

To be honest, I don't know what the error message even means. I read what the --enable-auto-import switch does from ld's man file but still I'm more than confused.

I can reprocude the error just writing 'TiXmlText textNode("test");' to a source file and compiling/linking. 'TiXmlElement elementNode("test");' works fine.
« Last Edit: August 09, 2006, 09:39:05 pm by artoj »

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: TiXmlText causes auto-import linker errors
« Reply #3 on: August 09, 2006, 09:46:01 pm »
To be honest, I don't know what the error message even means.
You normally only get that error under some specific condtions if you directly link to a DLL (without an import library).

I can reprocude the error just writing 'TiXmlText textNode("test");' to a source file and compiling/linking. 'TiXmlElement elementNode("test");' works fine.
I don't know what makes it fail for your plugin, but if you look at configmanager.cpp, line 992, you'll see that it does work fine for the main app. Hmm... no idea what to say really.  :?

Could it be some build flag that's different somewhere? Something like TIXML_USE_STL or such? Maybe the linker does not find the right function in the import lib for such a reason and then tries to get it from the DLL (which is, by accident, added to the project, too...?)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline artoj

  • Almost regular
  • **
  • Posts: 206
  • Location: Supporting my team
    • http://ajonsson.kapsi.fi/
Re: TiXmlText causes auto-import linker errors
« Reply #4 on: August 09, 2006, 10:42:36 pm »
I did some testing; there are other TiXml* classes that don't work too. The weird thing is that some of the classes work from the heap but refuse to work from stack (the same linker errors).

TiXmlDocument: stack - errors, heap - no errors
TiXmlComment: stack and heap - errors
TiXmlDeclaration: stack and heap - errors
TiXmlText: stack and heap - errors
TiXmlElement - stack and heap - no errors

I also deleted all the DLL files from the devel directory but the error messages remain.

*sigh* :(

Offline artoj

  • Almost regular
  • **
  • Posts: 206
  • Location: Supporting my team
    • http://ajonsson.kapsi.fi/
Re: TiXmlText causes auto-import linker errors
« Reply #5 on: August 10, 2006, 09:06:38 pm »
I don't know what makes it fail for your plugin, but if you look at configmanager.cpp, line 992, you'll see that it does work fine for the main app. Hmm... no idea what to say really.  :?

This works on the main DLL library i.e. libcodeblocks but it doesn't work in the main application. I just tested it. If I add "TiXmlDocument doc;" anywhere on the app.cpp the linker phase fails.

If I add the same line to any plugin (contrib/non-contrib) the linker phase fails.

I've tested it with GCC 3.4.2 and GCC 4.1.1 and they both fail.

If I use "TiXmlElement element("test");" the linking phase is passed without any errors.

I'm really lost here; I have no idea what is happening. :?

Could someone please try to reproduce this (on Windows).
« Last Edit: August 10, 2006, 09:08:19 pm by artoj »