News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Library linking in C::B? Am I being stupid?

Started by acron^, November 19, 2006, 02:11:26 PM

Previous topic - Next topic

acron^

OK, I only started using Code::Blocks recently, as it's quite easy to setup a good toolchain when developing for the 'GP2X'.
It's a Linux-based handheld console.

Anyway, I know the toolchain is working fine and is all setup OK because i've been compiling stuff with no issues. Recently, however, I came to include tinyXML in a wrapper I created a while ago called tinyWrap. Baring in mind i'm a Visual Studio zealot, I am obviously doing something hideously wrong here because even though I *think* I'm linked with the libraries correctly, I'm still receiving the following error:


.objs\tW_Element.o: In function `tW_Element::GetChild(char const*)':
tW_Element.cpp:(.text+0x288): undefined reference to `TiXmlNode::FirstChildElement(char const*)'
.objs\tW_Element.o: In function `tW_Element::GetNextSibling(char const*)':
tW_Element.cpp:(.text+0x338): undefined reference to `TiXmlNode::NextSiblingElement(char const*)'
.objs\tW_Element.o: In function `tW_Element::GetChildCount(char const*)':
tW_Element.cpp:(.text+0x3dc): undefined reference to `TiXmlNode::FirstChildElement(char const*)'
tW_Element.cpp:(.text+0x430): undefined reference to `TiXmlNode::NextSiblingElement(char const*)'
.objs\tW_Element.o: In function `tW_Element::AttributeInt(char const*)':
tW_Element.cpp:(.text+0x524): undefined reference to `TiXmlElement::Attribute(char const*, int*) const'
.objs\tW_Element.o: In function `tW_Element::AttributeDouble(char const*)':
tW_Element.cpp:(.text+0x564): undefined reference to `TiXmlElement::Attribute(char const*, double*) const'
.objs\tW_Element.o: In function `tW_Element::AttributeChars(char const*)':
tW_Element.cpp:(.text+0x5a8): undefined reference to `TiXmlElement::Attribute(char const*) const'
.objs\tW_Element.o: In function `tW_Element::AttributeWChars(char const*, wchar_t*)':
tW_Element.cpp:(.text+0x5f0): undefined reference to `TiXmlElement::Attribute(char const*) const'
.objs\tW_Element.o: In function `tW_Element::ParseFloat(float*)':
tW_Element.cpp:(.text+0x638): undefined reference to `TiXmlElement::GetText() const'
.objs\tW_Element.o: In function `tW_Element::ParseFloatArray(float*, int)':
tW_Element.cpp:(.text+0x780): undefined reference to `TiXmlElement::GetText() const'
.objs\tW_Element.o: In function `tW_Element::ParseVector(float*)':
tW_Element.cpp:(.text+0x938): undefined reference to `TiXmlElement::GetText() const'
.objs\tW_Element.o: In function `tW_Element::ParseVectorArray(float*, int)':
tW_Element.cpp:(.text+0xaf0): undefined reference to `TiXmlElement::GetText() const'
.objs\tW_Element.o: In function `tW_Element::ParseIntArray(int*, int)':
tW_Element.cpp:(.text+0xcc0): undefined reference to `TiXmlElement::GetText() const'
.objs\tinyWrap.o: In function `tinyWrap::tinyWrap()':
tinyWrap.cpp:(.text+0x58): undefined reference to `TiXmlDocument::TiXmlDocument()'
.objs\tinyWrap.o: In function `tinyWrap::tinyWrap()':
tinyWrap.cpp:(.text+0x198): undefined reference to `TiXmlDocument::TiXmlDocument()'
.objs\tinyWrap.o: In function `tinyWrap::OpenFile(char const*)':
tinyWrap.cpp:(.text+0x4c8): undefined reference to `TiXmlDocument::TiXmlDocument(char const*)'
tinyWrap.cpp:(.text+0x4e0): undefined reference to `TiXmlDocument::operator=(TiXmlDocument const&)'
tinyWrap.cpp:(.text+0x4f0): undefined reference to `TiXmlDocument::LoadFile(TiXmlEncoding)'
.objs\tinyWrap.o: In function `tinyWrap::SetRoot(char const*)':
tinyWrap.cpp:(.text+0x614): undefined reference to `TiXmlNode::FirstChildElement(char const*)'
.objs\tinyWrap.o: In function `TiXmlString::quit()':
tinyWrap.cpp:(.gnu.linkonce.t._ZN11TiXmlString4quitEv[_ZN11TiXmlString4quitEv]+0x4c): undefined reference to `TiXmlString::nullrep_'
.objs\tinyWrap.o: In function `TiXmlDocument::~TiXmlDocument()':
tinyWrap.cpp:(.gnu.linkonce.t._ZN13TiXmlDocumentD1Ev[_ZN13TiXmlDocumentD1Ev]+0x40): undefined reference to `TiXmlNode::~TiXmlNode()'
tinyWrap.cpp:(.gnu.linkonce.t._ZN13TiXmlDocumentD1Ev[_ZN13TiXmlDocumentD1Ev]+0x60): undefined reference to `vtable for TiXmlDocument'
Process terminated with status 1 (0 minutes, 2 seconds)


As far as I can see, this can only be a linker error.

To link the libraries (lib\tinyxmld.lib and lib\tinyxml.lib) I am going to the project's Build Options -> Linker & adding both these library files into "Link Libraries".

So...what am I doing wrong? :s

(I am using a custom compiler with custom rules - is there something I have to setup to explicity allow linking?)

MortenMacFly

Please enable "full logging" for the compilation process (see my sig) and post again so that we can inspect the command line that get's issued.
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

acron^

#2
Ok, this is everything:


Switching to target: default
arm-linux-g++.exe   -Wall -g     -IC:\devkitpro\devkitGP2X\include -IC:\devkitpro\devkitGP2X\lib\gcc\arm-linux\4.0.2\include -IC:\devkitpro\devkitGP2X\include\SDL -c CVisEntity.cpp -o .objs\CVisEntity.o
arm-linux-g++.exe   -Wall -g     -IC:\devkitpro\devkitGP2X\include -IC:\devkitpro\devkitGP2X\lib\gcc\arm-linux\4.0.2\include -IC:\devkitpro\devkitGP2X\include\SDL -c CVisualisation.cpp -o .objs\CVisualisation.o
CVisEntity.h:18: warning: 'class CVisEntity' has virtual functions but non-virtual destructor
arm-linux-g++.exe   -Wall -g     -IC:\devkitpro\devkitGP2X\include -IC:\devkitpro\devkitGP2X\lib\gcc\arm-linux\4.0.2\include -IC:\devkitpro\devkitGP2X\include\SDL -c main.cpp -o .objs\main.o
CVisEntity.h:18: warning: 'class CVisEntity' has virtual functions but non-virtual destructor
arm-linux-g++.exe   -Wall -g     -IC:\devkitpro\devkitGP2X\include -IC:\devkitpro\devkitGP2X\lib\gcc\arm-linux\4.0.2\include -IC:\devkitpro\devkitGP2X\include\SDL -c tW_Element.cpp -o .objs\tW_Element.o
tW_Element.cpp:6: warning: ignoring #pragma warning
arm-linux-g++.exe   -Wall -g     -IC:\devkitpro\devkitGP2X\include -IC:\devkitpro\devkitGP2X\lib\gcc\arm-linux\4.0.2\include -IC:\devkitpro\devkitGP2X\include\SDL -c tinyWrap.cpp -o .objs\tinyWrap.o
arm-linux-g++.exe   -Wall -g     -IC:\devkitpro\devkitGP2X\include -IC:\devkitpro\devkitGP2X\lib\gcc\arm-linux\4.0.2\include -IC:\devkitpro\devkitGP2X\include\SDL -c vector.cpp -o .objs\vector.o
arm-linux-g++.exe   -Wall -g     -IC:\devkitpro\devkitGP2X\include -IC:\devkitpro\devkitGP2X\lib\gcc\arm-linux\4.0.2\include -IC:\devkitpro\devkitGP2X\include\SDL -c CInput.cpp -o .objs\CInput.o
arm-linux-g++.exe   -Llib  -LC:\devkitpro\devkitGP2X\lib -o "H:\My Documents\Uni\Year 3\GP2X\My Code\SDLEngine\Game.gpe" .objs\CVisEntity.o .objs\CVisualisation.o .objs\main.o .objs\tW_Element.o .objs\tinyWrap.o .objs\vector.o .objs\CInput.o     -static -lSDL_gfx -lSDL_ttf -lfreetype -lSDL_image -ljpeg -lpng12 -lz -lSDL_mixer -lvorbisidec -lmikmod -lsmpeg -lSDL -lgcc -lm -lc -lexpat -lpthread    lib\tinyxmld.lib lib\tinyxml.lib  -mwindows
.objs\tW_Element.o: In function `tW_Element::GetChild(char const*)':
H:\My Documents\Uni\Year 3\GP2X\My Code\SDLEngine_txml/tW_Element.cpp:107: undefined reference to `TiXmlNode::FirstChildElement(char const*)'
.objs\tW_Element.o: In function `tW_Element::GetNextSibling(char const*)':
H:\My Documents\Uni\Year 3\GP2X\My Code\SDLEngine_txml/tW_Element.cpp:128: undefined reference to `TiXmlNode::NextSiblingElement(char const*)'
.objs\tW_Element.o: In function `tW_Element::GetChildCount(char const*)':
H:\My Documents\Uni\Year 3\GP2X\My Code\SDLEngine_txml/tW_Element.cpp:148: undefined reference to `TiXmlNode::FirstChildElement(char const*)'
H:\My Documents\Uni\Year 3\GP2X\My Code\SDLEngine_txml/tW_Element.cpp:153: undefined reference to `TiXmlNode::NextSiblingElement(char const*)'
.objs\tW_Element.o: In function `tW_Element::AttributeInt(char const*)':
H:\My Documents\Uni\Year 3\GP2X\My Code\SDLEngine_txml/tW_Element.cpp:173: undefined reference to `TiXmlElement::Attribute(char const*, int*) const'
.objs\tW_Element.o: In function `tW_Element::AttributeDouble(char const*)':
H:\My Documents\Uni\Year 3\GP2X\My Code\SDLEngine_txml/tW_Element.cpp:191: undefined reference to `TiXmlElement::Attribute(char const*, double*) const'
.objs\tW_Element.o: In function `tW_Element::AttributeChars(char const*)':
H:\My Documents\Uni\Year 3\GP2X\My Code\SDLEngine_txml/tW_Element.cpp:208: undefined reference to `TiXmlElement::Attribute(char const*) const'
.objs\tW_Element.o: In function `tW_Element::AttributeWChars(char const*, wchar_t*)':
H:\My Documents\Uni\Year 3\GP2X\My Code\SDLEngine_txml/tW_Element.cpp:215: undefined reference to `TiXmlElement::Attribute(char const*) const'
.objs\tW_Element.o: In function `tW_Element::ParseFloat(float*)':
H:\My Documents\Uni\Year 3\GP2X\My Code\SDLEngine_txml/tW_Element.cpp:232: undefined reference to `TiXmlElement::GetText() const'
.objs\tW_Element.o: In function `tW_Element::ParseFloatArray(float*, int)':
H:\My Documents\Uni\Year 3\GP2X\My Code\SDLEngine_txml/tW_Element.cpp:277: undefined reference to `TiXmlElement::GetText() const'
.objs\tW_Element.o: In function `tW_Element::ParseVector(float*)':
H:\My Documents\Uni\Year 3\GP2X\My Code\SDLEngine_txml/tW_Element.cpp:322: undefined reference to `TiXmlElement::GetText() const'
.objs\tW_Element.o: In function `tW_Element::ParseVectorArray(float*, int)':
H:\My Documents\Uni\Year 3\GP2X\My Code\SDLEngine_txml/tW_Element.cpp:370: undefined reference to `TiXmlElement::GetText() const'
.objs\tW_Element.o: In function `tW_Element::ParseIntArray(int*, int)':
H:\My Documents\Uni\Year 3\GP2X\My Code\SDLEngine_txml/tW_Element.cpp:419: undefined reference to `TiXmlElement::GetText() const'
.objs\tinyWrap.o: In function `tinyWrap':
H:\My Documents\Uni\Year 3\GP2X\My Code\SDLEngine_txml/tinyWrap.cpp:15: undefined reference to `TiXmlDocument::TiXmlDocument()'
H:\My Documents\Uni\Year 3\GP2X\My Code\SDLEngine_txml/tinyWrap.cpp:15: undefined reference to `TiXmlDocument::TiXmlDocument()'
.objs\tinyWrap.o: In function `tinyWrap::OpenFile(char const*)':
H:\My Documents\Uni\Year 3\GP2X\My Code\SDLEngine_txml/tinyWrap.cpp:42: undefined reference to `TiXmlDocument::TiXmlDocument(char const*)'
H:\My Documents\Uni\Year 3\GP2X\My Code\SDLEngine_txml/tinyWrap.cpp:43: undefined reference to `TiXmlDocument::operator=(TiXmlDocument const&)'
H:\My Documents\Uni\Year 3\GP2X\My Code\SDLEngine_txml/tinyWrap.cpp:45: undefined reference to `TiXmlDocument::LoadFile(TiXmlEncoding)'
.objs\tinyWrap.o: In function `tinyWrap::SetRoot(char const*)':
H:\My Documents\Uni\Year 3\GP2X\My Code\SDLEngine_txml/tinyWrap.cpp:71: undefined reference to `TiXmlNode::FirstChildElement(char const*)'
.objs\tinyWrap.o: In function `TiXmlString::quit()':
H:\My Documents\Uni\Year 3\GP2X\My Code\SDLEngine_txml/tinystr.h:261: undefined reference to `TiXmlString::nullrep_'
.objs\tinyWrap.o: In function `~TiXmlDocument':
H:\My Documents\Uni\Year 3\GP2X\My Code\SDLEngine_txml/tinyxml.h:1235: undefined reference to `TiXmlNode::~TiXmlNode()'
H:\My Documents\Uni\Year 3\GP2X\My Code\SDLEngine_txml/tinyxml.h:1235: undefined reference to `vtable for TiXmlDocument'
Process terminated with status 1 (0 minutes, 3 seconds)


That's the code with -g, "full logging" and rebuilt.

The 'linker options' command line is:

-static -lSDL_gfx -lSDL_ttf -lfreetype -lSDL_image -ljpeg -lpng12 -lz -lSDL_mixer -lvorbisidec -lmikmod -lsmpeg -lSDL -lgcc -lm -lc -lexpat -lpthread

and the one from the above code simply adds...

    lib\tinyxmld.lib lib\tinyxml.lib  -mwindows

...to the end of it.

As this is the first time I've used a 'linker option' like this, am I accidentally omitting anything here?

MortenMacFly

#3
Quote from: acron^ on November 19, 2006, 03:11:27 PM
and the one from the above code simply adds...
    lib\tinyxmld.lib lib\tinyxml.lib  -mwindows
Are you sure, that you can link these libs with the "arm-linux-g++.exe" compiler? Is it possible that you first have to create the tinyxml library with that compiler, too?
In addition: You seem to use a linux cross-compiler on windows. So why are you using -mwindows then?!
And another option: Did you compile the tinyxml library with TIXML_USE_STL but not using this for linking?
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

acron^