1

I'm using vagrant to build the same code under multiple versions of Ubuntu (12.04, 14.04 and 16.04).

Under 16.04, I have a missing symbol:

undefined reference to TiXmlElement::TiXmlElement(std::string const&)

The linkage is done with the same version of libtinyxml (see below), but when I look at the symbols inside the libraries, there's a small difference:

Ubuntu 14.04:

$ ldd libcustomlib.so
libtinyxml.so.2.6.2 => /usr/lib/x86_64-linux-gnu/libtinyxml.so.2.6.2 (0x00007fe6c9789000)
$ objdump -TC /usr/lib/x86_64-linux-gnu/libtinyxml.so.2.6.2 | grep "TiXmlElement::TiXmlElement(std"
000000000000a0f0 g  DF .text  0000000000000072  Base  TiXmlElement::TiXmlElement(std::string const&)
000000000000a0f0 g  DF .text  0000000000000072  Base  TiXmlElement::TiXmlElement(std::string const&)

Ubuntu 16.04:

$ ldd libcustomlib.so
libtinyxml.so.2.6.2 => /usr/lib/x86_64-linux-gnu/libtinyxml.so.2.6.2 (0x00007f08eb3c0000)
$ objdump -TC /usr/lib/x86_64-linux-gnu/libtinyxml.so.2.6.2 | grep "TiXmlElement::TiXmlElement(std"
000000000000aad0 g  DF .text  0000000000000072  Base  TiXmlElement::TiXmlElement(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
000000000000aad0 g  DF .text  0000000000000072  Base  TiXmlElement::TiXmlElement(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)

As you can see, under 16.04, the library seems to have been built with c++11 while not under 14.04.

How is that since the version number is the same? And what can I do to make my code compile?

Jav
  • 1,445
  • 1
  • 18
  • 47
  • Is updating your toolchain an option? – StoryTeller - Unslander Monica Jan 04 '17 at 17:49
  • I'm not sure I fully understood the suggestion but most of our developers don't use c++11 so I don't want to force using it. – Jav Jan 04 '17 at 17:54
  • My suggestion stems from the symbols you showed. `libtinyxml 16.04` is built using a different version of the standard library than `14.04`. Since binary compatibility isn't promised here, you need to update your toolchain. Also, using a compiler which supports C++11/14 doesn't mean you need to start using all the new language features. You can still write what is pretty much legal C++03. – StoryTeller - Unslander Monica Jan 04 '17 at 17:57
  • Or you can try to do what this post did http://stackoverflow.com/questions/33394934/converting-std-cxx11string-to-stdstring – StoryTeller - Unslander Monica Jan 04 '17 at 18:00
  • I'm using g++ 4.8.5. I tried to define the macro `#define _GLIBCXX_USE_CXX11_ABI 1` but doesn't change anything, the compilation still tries to use the `std::string const&` and not the `std::__cxx11::basic_string, std::allocator > const&`. – Jav Jan 05 '17 at 08:25
  • 1
    It didn't help because your toolchain doesn't support the C++11 ABI... Of course *enabling* the ABI won't help. Your options are limited to updating your toolchain or building TinyXml from source with `_GLIBCXX_USE_CXX11_ABI 0`. – StoryTeller - Unslander Monica Jan 05 '17 at 08:36

1 Answers1

0

The problem was related to a different gcc version.

The best thing is to use under each Ubuntu, the gcc that is in the default repositories.

Jav
  • 1,445
  • 1
  • 18
  • 47