我正在对 QT 应用程序进行从 Debian (Stretch) PC 到 Debian (Jessie) BeagleBone Black 的交叉构建,当我执行此操作时,我收到了消息
/home/bbuser/totemguard/totemguard: /usr/lib/arm-linux-gnueabihf/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by /home/bbuser/totemguard/totemguard)
我看到 armhf g++ 版本是 6.1,所以我安装了 4.9.2-10(与我在 BeagleBone Black 上安装的相同)并重新编译我的代码,结果相似(不同的 GLIBXX 版本):
/home/bbuser/totemguard/totemguard: /usr/lib/arm-linux-gnueabihf/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/bbuser/totemguard/totemguard)
阅读ABI Policy and Guidelines , GLIBCXX_3.4.21 的 G++ 版本是 5.1.0:
GCC 4.9.0: GLIBCXX_3.4.20, CXXABI_1.3.8
GCC 5.1.0: GLIBCXX_3.4.21, CXXABI_1.3.9
GCC 6.1.0: GLIBCXX_3.4.22, CXXABI_1.3.10
但我从未在主机 PC 或 BeagleBone Black 开发板上安装 5.1 版本。
列出/usr/lib/arm-linux-gnueabihf/目录可以看到只有GCC 4.9.0和GCC 6.1.0 libstdc++版本:
lrwxrwxrwx 1 root root 19 ago 3 15:53 libstdc++.so.6 -> libstdc++.so.6.0.22
-rw-r--r-- 1 root root 658064 dic 27 2014 libstdc++.so.6.0.20
-rw-r--r-- 1 root root 1019632 ago 3 15:53 libstdc++.so.6.0.22
这个问题在从 jessie 到 stretch 的发行版升级后开始,我无法升级 beaglebone black gcc 版本。
我能做什么?
编辑 1: 在测试板 (BeagleBone Black) 上,我添加了拉伸(stretch)存储库并执行了以下操作:
bbuser@beaglebone:~/totemguard$ sudo apt-cache policy libstdc++6
libstdc++6:
Installed: 4.9.2-10
Candidate: 6.1.1-11
Version table:
6.1.1-11 0
500 http://ftp.us.debian.org/debian/ stretch/main armhf Packages
*** 4.9.2-10 0
500 http://ftp.us.debian.org/debian/ jessie/main armhf Packages
100 /var/lib/dpkg/status
bbuser@beaglebone:~/totemguard$ sudo apt-get install libstdc++6
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
gcc-6-base
The following NEW packages will be installed:
gcc-6-base
The following packages will be upgraded:
libstdc++6
1 upgraded, 1 newly installed, 0 to remove and 726 not upgraded.
Need to get 517 kB of archives.
...
应用程序运行良好(未经过 100% 测试,但未出现任何错误)。这仍然是一个测试板,我不能在生产板上做同样的事情。
最佳答案
解决方案 1)使用 -static(完整库)或仅编译 libstdc++ 作为二进制文件的静态
解决方案 2) 使用二进制文件分发适当的 libstdc++ 版本(可能使用 LD_PRELOAD)
解决方案 3)使用完全相同的 g++ libstdc++ 版本进行交叉编译(至少匹配)
通常更好的方法是使用解决方案 1) - 跨发行版升级不会有问题
关于c++ - 针对特定版本的 armhf g++ 进行编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39985080/