lizh06 / ticpp

Automatically exported from code.google.com/p/ticpp
0 stars 0 forks source link

Trying to link against ticpp and seeing some weirdness #21

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I am trying to link again ticpp with a very simple example of a program
(it's not meant to do anything, just a proof of linking with ticpp
successfully). The source of the program is the following:

#define TIXML_USE_TICPP

#include "ticpp.h"

int main()
{
    ticpp::Document xmldoc;

    return 0;
}

To compile, I issued this at my command line: g++ main.cpp -L/usr/lib -lticpp

libticpp.a is definitely located in /usr/lib/

To create the libticpp.a static library, I did a premake with the command
flag of: premake --target gnu

I'm not exactly sure why, but I get linking errors as follows:

drew@schumi:~/Projects/test_ticpp$ g++ main.cpp -L/usr/lib -lticpp
/tmp/ccRYFUpH.o: In function `main':
main.cpp:(.text+0x195): undefined reference to `ticpp::Document::Document()'
/tmp/ccRYFUpH.o: In function
`ticpp::NodeImp<TiXmlDocument>::operator=(ticpp::NodeImp<TiXmlDocument>
const&)':
main.cpp:(.text._ZN5ticpp7NodeImpI13TiXmlDocumentEaSERKS2_[ticpp::NodeImp<TiXmlD
ocument>::operator=(ticpp::NodeImp<TiXmlDocument>
const&)]+0x1b): undefined reference to `TiCppRCImp::DecRef()'
main.cpp:(.text._ZN5ticpp7NodeImpI13TiXmlDocumentEaSERKS2_[ticpp::NodeImp<TiXmlD
ocument>::operator=(ticpp::NodeImp<TiXmlDocument>
const&)]+0x3e): undefined reference to `TiCppRCImp::IncRef()'
/tmp/ccRYFUpH.o: In function `ticpp::NodeImp<TiXmlDocument>::~NodeImp()':
main.cpp:(.text._ZN5ticpp7NodeImpI13TiXmlDocumentED2Ev[ticpp::NodeImp<TiXmlDocum
ent>::~NodeImp()]+0x26):
undefined reference to `TiCppRCImp::DecRef()'
/tmp/ccRYFUpH.o: In function `ticpp::NodeImp<TiXmlDocument>::~NodeImp()':
main.cpp:(.text._ZN5ticpp7NodeImpI13TiXmlDocumentED0Ev[ticpp::NodeImp<TiXmlDocum
ent>::~NodeImp()]+0x26):
undefined reference to `TiCppRCImp::DecRef()'
/tmp/ccRYFUpH.o: In function `ticpp::NodeImp<TiXmlDocument>::~NodeImp()':
main.cpp:(.text._ZN5ticpp7NodeImpI13TiXmlDocumentED1Ev[ticpp::NodeImp<TiXmlDocum
ent>::~NodeImp()]+0x26):
undefined reference to `TiCppRCImp::DecRef()'
/tmp/ccRYFUpH.o: In function `ticpp::Base::ValidatePointer() const':
main.cpp:(.text._ZNK5ticpp4Base15ValidatePointerEv[ticpp::Base::ValidatePointer(
)
const]+0x14): undefined reference to `TiCppRCImp::IsNull()'
main.cpp:(.text._ZNK5ticpp4Base15ValidatePointerEv[ticpp::Base::ValidatePointer(
)
const]+0x1b8): undefined reference to
`ticpp::Exception::Exception(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)'
main.cpp:(.text._ZNK5ticpp4Base15ValidatePointerEv[ticpp::Base::ValidatePointer(
)
const]+0x22e): undefined reference to `ticpp::Exception::~Exception()'
main.cpp:(.text._ZNK5ticpp4Base15ValidatePointerEv[ticpp::Base::ValidatePointer(
)
const]+0x236): undefined reference to `typeinfo for ticpp::Exception'
/tmp/ccRYFUpH.o: In function
`ticpp::Node::IterateFirst(std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&, ticpp::Attribute**) const':
main.cpp:(.text._ZNK5ticpp4Node12IterateFirstERKSsPPNS_9AttributeE[ticpp::Node::
IterateFirst(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&, ticpp::Attribute**)
const]+0x1a2): undefined reference to
`ticpp::Exception::Exception(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)'
main.cpp:(.text._ZNK5ticpp4Node12IterateFirstERKSsPPNS_9AttributeE[ticpp::Node::
IterateFirst(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&, ticpp::Attribute**)
const]+0x218): undefined reference to `ticpp::Exception::~Exception()'
main.cpp:(.text._ZNK5ticpp4Node12IterateFirstERKSsPPNS_9AttributeE[ticpp::Node::
IterateFirst(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&, ticpp::Attribute**)
const]+0x220): undefined reference to `typeinfo for ticpp::Exception'
collect2: ld returned 1 exit status

Original issue reported on code.google.com by james.ho...@gmail.com on 11 Jun 2008 at 4:58

GoogleCodeExporter commented 9 years ago
try this on your command line, just to be sure you're linking to the file that 
you
think you are.
g++ main.cpp -l/usr/lib/libticpp.a

Original comment by rjmy...@gmail.com on 12 Jun 2008 at 12:14

GoogleCodeExporter commented 9 years ago
flagging this as fixed until you respond

Original comment by rjmy...@gmail.com on 8 Jul 2008 at 12:10

GoogleCodeExporter commented 9 years ago
I tried your suggestion and it didn't do anything different.

Original comment by james.ho...@gmail.com on 8 Jul 2008 at 12:55

GoogleCodeExporter commented 9 years ago
Could you run
nm -C libticppd.a > ticpp_symbols.txt
and post ticpp_symbols.txt here?

Original comment by rjmy...@gmail.com on 8 Jul 2008 at 2:24

GoogleCodeExporter commented 9 years ago
It is possible to get linker errors similar to those posted by James by 
compiling
ticpp.cpp WITHOUT the macro TIXML_USE_TICPP defined (resulting in a practically 
empty
object file), compiling main.cpp WITH the macro TIXML_USE_TICPP defined, and 
then
trying to link the resulting objects (and the tinyxml-objects).

If not using one of the build scripts, you can use "g++ -DTIXML_USE_TICPP -c 
*.cpp"
to create all the object files correctly and they will link without errors.

Original comment by goo...@manumark.de on 17 Oct 2008 at 7:39

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
hi, 
  i too got the same error while i was trying to do the same thing 
  what james.hodapp did. But it got resolved as i did what mentioned in above comment.

  g++ -DTIXML_USE_TICPP -c *.cpp
  g++ -o xmltest *.o

  Thankyou very much for that.
-
Phani

Original comment by phanidee on 21 Apr 2009 at 5:15

GoogleCodeExporter commented 9 years ago
Closed sinse this was not an issue

Original comment by rpusz...@gmail.com on 21 Apr 2009 at 6:57