9

I have the following program:

#include <iostream>
#include <sstream>
using namespace std;

int main()
{
    //ostringstream s;
    cout << "cpp test" << endl;
    return 0;
}

I build it on Ububtu 20.04 desktop using cross-compiler:

arm-linux-gnueabihf-g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/cpp_test.d" -MT"src/cpp_test.o" -o "src/cpp_test.o" "../src/cpp_test.cpp"
arm-linux-gnueabihf-g++  -o "cpp_test"  ./src/cpp_test.o

Then I copy cpp_test to BeagleBone Black Wireless board and execute it:

debian@beaglebone:~/c$ ./cpp_test 
cpp test
debian@beaglebone:~/c$ ldd cpp_test
    linux-vdso.so.1 (0xbee85000)
    libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0xb6ea1000)
    libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xb6e78000)
    libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6d7e000)
    libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xb6d03000)
    /lib/ld-linux-armhf.so.3 (0xb6fbe000)

Now I uncomment the line ostringstream s;, build the program, copy it to BeagleBone and execute:

debian@beaglebone:~/c$ ./cpp_test 
./cpp_test: /usr/lib/arm-linux-gnueabihf/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by ./cpp_test)
debian@beaglebone:~/c$ ldd cpp_test
./cpp_test: /usr/lib/arm-linux-gnueabihf/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by ./cpp_test)
    linux-vdso.so.1 (0xbefa6000)
    libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0xb6e22000)
    libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6d28000)
    /lib/ld-linux-armhf.so.3 (0xb6f3f000)
    libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xb6cad000)
    libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xb6c84000)

Additional information from the board:

debian@beaglebone:/usr/lib/arm-linux-gnueabihf$ ls -l | grep libstdc++.so.6
lrwxrwxrwx  1 root root       19 Apr  6  2019 libstdc++.so.6 -> libstdc++.so.6.0.25
-rw-r--r--  1 root root  1019772 Apr  6  2019 libstdc++.so.6.0.25
debian@beaglebone:/usr/lib/arm-linux-gnueabihf$ uname -r
4.19.94-ti-r45
debian@beaglebone:/usr/lib/arm-linux-gnueabihf$ uname -a
Linux beaglebone 4.19.94-ti-r45 #1buster SMP PREEMPT Thu Jun 18 19:18:41 UTC 2020 armv7l GNU/Linux
debian@beaglebone:~$ strings /usr/lib/arm-linux-gnueabihf/libstdc++.so.6.0.25 | grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
...
GLIBCXX_3.4.24
GLIBCXX_3.4.25

Additional information from the host:

alex@alex-u20:~$ arm-linux-gnueabihf-g++ -v
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabihf-g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/arm-linux-gnueabihf/9/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-10ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --without-target-system-zlib --enable-libpth-m2 --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-werror --enable-multilib --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueabihf --program-prefix=arm-linux-gnueabihf- --includedir=/usr/arm-linux-gnueabihf/include
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-10ubuntu1)

alex@alex-u20:/usr/lib/x86_64-linux-gnu$ strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28 | grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
...
GLIBCXX_3.4.24
GLIBCXX_3.4.25
GLIBCXX_3.4.26
GLIBCXX_3.4.27
GLIBCXX_3.4.28

Finally, this program runs on the desktop using qemu:

alex@alex-u20:~/tmp/cpp_test/Debug$ qemu-arm-static -L /usr/arm-linux-gnueabihf/ cpp_test
cpp test

Both computers, host and BB board, are completely updated.

9
  • Suggests you're using the wrong toolchain maybe? Check your GCC version... Jul 31, 2020 at 10:41
  • @AsteroidsWithWings: the answer updated, see Additional information from the host
    – Alex F
    Jul 31, 2020 at 10:45
  • What's the version of Ubuntu on the BeagleBone? Jul 31, 2020 at 10:49
  • libstdc++.so.6.0.25 vs GLIBCXX_3.4.26? Jul 31, 2020 at 10:52
  • @AsteroidsWithWings: Linux beaglebone 4.19.94-ti-r45 #1buster SMP PREEMPT Thu Jun 18 19:18:41 UTC 2020 armv7l GNU/Linux
    – Alex F
    Jul 31, 2020 at 11:50

3 Answers 3

21

GLIBCXX_3.4.26 comes with gcc-8. Installing gcc-8 and upgrading libstdc++6 worked for me. Run the following as shown here:

sudo apt update
sudo apt install wget gcc-8 unzip libssl1.0.0 software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt-get install --only-upgrade libstdc++6
1
  • 1
    Is there any way to get an updated libstdc++.so.6 for armv7l without use apt (to a Yocto project based distro) ? I already have gcc-9 in my host computer (Ubuntu WSL x86_64) however in my target (armv7l ) I had an outdated version of libstdc++.so.6
    – Lincoln
    Oct 10, 2022 at 21:56
8

Not really an answer, but on my Ubuntu 20.04 system, I have package libstdc++6 installed, containing libstdc++.so.6.0.28.

Looking for symbols

strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28 | grep GLIBCXX

gives

...
GLIBCXX_3.4.19
GLIBCXX_3.4.20
GLIBCXX_3.4.21
GLIBCXX_3.4.22
GLIBCXX_3.4.23
GLIBCXX_3.4.24
GLIBCXX_3.4.25
GLIBCXX_3.4.26
GLIBCXX_3.4.27
GLIBCXX_3.4.28
...

So, it seems, version 6.0.28 corresponds to symbol 3.4.28.

In your case, you have libstdc++.so.6.0.25 installed, which is just one less than GLIBCXX_3.4.26. So, you must either upgrade the Beagle board, or downgrade the dev environment.


Current (focal, 20.04) libstdc++6 version is 6.0.28. Version 6.0.25 is contained in bionic (18.04), which also contains gcc-8.

So, maybe installing package gcc-8/g++-8 and its dependencies (e.g. libstdc++-8-dev) solves this.

2
  • Thanks, the reason is correct. The simplest solution I have for now is to switch to Linaro toolchain.
    – Alex F
    Jul 31, 2020 at 14:41
  • @AlexF Another solution could be to create a docker container with Ubuntu 18.04 or the corresponding Debian release. Jul 31, 2020 at 15:50
0

You may not have Debian 11 as OS, 3.4.26 is not available for Debian 10. After upgrading to Debian 10, I could run the program without error.

2
  • 1
    You mean after "upgrading to Debian 11", right?
    – Mark Jin
    Mar 2 at 21:57
  • i don't remember, sorry @MarkJin
    – Sahin
    Mar 3 at 22:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.