I am trying to compile QtWebApp with Qt5.5.1 onto the latest RPI4-Raspbian Buster and I am encountering inexplicable GLIBCXX unresolved symbols
What Works : QtWebApp cross compiled from windows to armhf using qt5.5.1 binaries natively compiled on Raspbian Buster works fine with the following components
Toolchain : raspberry-gcc8.3.0.exe installed on Windows 10.
Qt Binary Libs : Native compiled on RPI4 Raspbian Buster OS and copied over to Windows 10.
Command line :
c:/SysGCC/raspberry/bin/arm-linux-gnueabihf-g++.exe -std=c++11 -fPIC -I.
{ALL QT INCLUDE DIRS}
-IC:/SysGCC/raspberry/arm-linux-gnueabihf/sysroot/opt/vc/include
-g -rdynamic -funwind-tables -Woverflow
{ALL QTWEB SOURCE FILES}
-LC:/SysGCC/pi4/pi4qt551/lib
-lQt5Core -lQt5Gui -lQt5Widgets
-lQt5Multimedia -lQt5MultimediaWidgets
-lQt5Network -lm -lpthread -o qtweb
This produces an arm executable that worksfine on RPI-4.
What fails
When compiling natively (which is what I want as the development env) on RPI4 the compilation strangely fails with the following error :
/usr/bin/ld: /tmp/ccnnsRCD.o: undefined reference to symbol '_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev@@GLIBCXX_3.4.21'
What I have tried (didnt work)
1) Following suggestions from Converting std::__cxx11::string to std::string and passing -D_GLIBCXX_USE_CXX11_ABI=0
it fails with the following error :
/usr/bin/ld: /tmp/ccZfI5co.o: undefined reference to symbol '_ZNSaIcED1Ev@@GLIBCXX_3.4'
where those symbol demangles to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()
and std::allocator<char>::~allocator()
respectively.
2) I also ran all the combinations WITH/WITHOUT -std=c++11 and D_GLIBCXX_USE_CXX11_ABI=0
and these are the errors
WITH -std=c++11, WITHOUT -D_GLIBCXX_USE_CXX11_ABI=0
/usr/bin/ld: /tmp/ccnnsRCD.o: undefined reference to symbol '_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev@@GLIBCXX_3.4.21'
WITH -std=c++11, WITH -D_GLIBCXX_USE_CXX11_ABI=0
/usr/bin/ld: /tmp/ccZfI5co.o: undefined reference to symbol '_ZNSaIcED1Ev@@GLIBCXX_3.4'
WITHOUT -std=c++11, WITH -D_GLIBCXX_USE_CXX11_ABI=0
/usr/bin/ld: /tmp/cctFncwz.o: undefined reference to symbol '_ZNSaIcED1Ev@@GLIBCXX_3.4'
WITHOUT -std=c++11, WITHOUT -D_GLIBCXX_USE_CXX11_ABI=0
/usr/bin/ld: /tmp/cchkJYdO.o: undefined reference to symbol '_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev@@GLIBCXX_3.4.21'
3) I also copied the sysroot from the raspberry-gcc8.3.0.exe install on Win10 over to RPi-4 and passed that to gcc
as its --sysroot
location - which also fails with the ~basic_string()
unresolver error. (I dont know how to verify if the --sysroot
had any effect though I checked that gcc -v
output doesnt have --with_libs
in it as suggested in a GCC ignores --sysroot post)
INFO: The command line is exactly the same on the RPI4-Buster other than using gcc
and not passing -IC:/SysGCC/raspberry/arm-linux-gnueabihf/sysroot/opt/vc/include
Question : How is it that (assuming no glaring compile option mismatch ;) cross compiling with a gcc 8.3 toolchain from windows to arm-linux works but the same code base when compiled natively on raspbian buster with gcc 8.3 fails with what looks like GLIBCXX version mismatch in the Raspbian Buster OS binaries ?
I am stuck on this for 2 days now. Please suggest any other steps I can try here.
gcc
instead of g++
? That would cause this problem. Invoke g++
.-lstdc++
to your link flags.Explanation:
The symbols are, obviously, from the C++ standard library. Under some circumstances - at the very least, when you invoke GCC using the gcc
binary rather than g++
- GCC compiles C++ code, but doesn't automatically link against the GNU C++ standard library. If for some reason this isn't resolved by invoking g++
, you could try adding the -lstdc++
flag, which means "link against the library libstdc++.so
or libstdc++.a
which you should find in the library search path".