I have a library (let's call it libmylib.so) which was meant to be built using a docker running Ubuntu 16. I would like to use this library in a program (let's call it myapp) I wish to compile on my raspberry Pi running Raspbian.
When compiling, I get an output log of this form:
[25%] Building CXX object example1.cpp.o
[50%] Building CXX object example2.cpp.o
[75%] Building CXX object example3.cpp.o
[100%] Linking CXX executable target
And then a bunch of error of the form:
undefined reference to `VTT for std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >@GLIBCXX_3.4.21'
undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21'
collect2: error: ld returned 1 exit status
From what I could find on the web, this seems due to the fact that I am not compiling libmylib.so and myapp with the same compiler.
I am using g++ in both cases, but not the same version, as can be seen when I call g++ --version on both device.
From my docker:
root@3ea34286736e:/usr/bin# g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.6) 5.4.0 20160609
From my raspberry PI
pi@raspberrypi:/usr/bin $ g++ --version
g++ (Raspbian 4.9.2-10+deb8u1) 4.9.2
Is this a complete deal breaker or is there a way to make it work?
EDIT: Here is what I read that makes me assume it is a compiler version problem.
This and this seemed to be similar errors, to which the fix was to add to the cmake of myapp:
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
which did not work.
Adding this flag to the compile options of libmylib.so reduced the number of undefined reference errors from 10 to 1. More precisely:
undefined reference to `std::invalid_argument::invalid_argument(char const*)@GLIBCXX_3.4.21'