Android P 9.0 编译时报如下错误:
1 2 3 4 5 6 7 8 |
<span style="font-family: arial, helvetica, sans-serif;">FAILED: out/soong/.intermediates/external/protobuf/aprotoc/linux_glibc_x86_64/obj/external/protobuf/src/google/protobuf/dynamic_message.o PWD=/proc/self/cwd prebuilts/misc/linux-x86/ccache/ccache prebuilts/clang/host/linux-x86/clang-4691093/bin/clang++ -c -Iexternal/protobuf/android -Iexternal/protobuf/src -Iexternal/protobuf -Wa,--noexecstack -fPIC -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS --gcc-toolchain=prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8 --sysroot prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot -fstack-protector-strong -m64 -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith -no-canonical-prefixes -DNDEBUG -UDEBUG -fno-exceptions -Wno-multichar -O2 -g -fno-strict-aliasing -fdebug-prefix-map=/proc/self/cwd= -D__compiler_offsetof=__builtin_offsetof -Werror=int-conversion -Wno-reserved-id-macro -Wno-format-pedantic -Wno-unused-command-line-argument -fcolor-diagnostics -Wno-expansion-to-defined -Wno-zero-as-null-pointer-constant -fdebug-prefix-map=$PWD/= -Iexternal/zlib -Iexternal/libcxx/include -Iexternal/libcxxabi/include -Isystem/core/include -Isystem/media/audio/include -Ihardware/libhardware/include -Ihardware/libhardware_legacy/include -Ihardware/ril/include -Ilibnativehelper/include -Iframeworks/native/include -Iframeworks/native/opengl/include -Iframeworks/av/include -Ilibnativehelper/include_jni -Wall -Wno-error=format -Wno-error=format-extra-args -Wno-error=ignored-qualifiers -Wno-error=sign-promo -Wno-unused-function -Wno-sign-compare -Wno-unused-parameter -Wno-sign-promo -Wno-error=return-type -DHAVE_ZLIB=1 -Werror -Wno-error=unused-const-variable -Wno-error=user-defined-warnings -target x86_64-linux-gnu -Bprebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/x86_64-linux/bin -fPIE -D_USING_LIBCXX -std=gnu++14 -Wsign-promo -Wno-inconsistent-missing-override -Wno-null-dereference -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -Wno-thread-safety-negative -Wno-gnu-include-next -isystem prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/x86_64-linux/include/c++/4.8 -isystem prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/x86_64-linux/include/c++/4.8/backward -isystem prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/x86_64-linux/include/c++/4.8/x86_64-linux -nostdinc++ -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast -Werror=address-of-temporary -Werror=return-type -Wno-tautological-constant-compare -Wno-null-pointer-arithmetic -Wno-enum-compare -Wno-enum-compare-switch -MD -MF out/soong/.intermediates/external/protobuf/aprotoc/linux_glibc_x86_64/obj/external/protobuf/src/google/protobuf/dynamic_message.o.d -o out/soong/.intermediates/external/protobuf/aprotoc/linux_glibc_x86_64/obj/external/protobuf/src/google/protobuf/dynamic_message.o external/protobuf/src/google/protobuf/dynamic_message.cc prebuilts/clang/host/linux-x86/clang-4691093/bin/clang++.real: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.17' not found (required by /home/android/src/android_p0/prebuilts/clang/host/linux-x86/clang-4691093/bin/../lib64/libc++.so.1) prebuilts/clang/host/linux-x86/clang-4691093/bin/clang++.real: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.18' not found (required by /home/android/src/android_p0/prebuilts/clang/host/linux-x86/clang-4691093/bin/../lib64/libc++.so.1) ninja: build stopped: subcommand failed. 15:53:28 ninja failed with: exit status 1 [0;31m#### failed to build some targets (46 seconds) ####[00m</span> |
原因应该是ubuntu 版本太低 12.04, 要求最低版本:ubuntu 14.04
glibc 版本为2.15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<span style="font-family: arial, helvetica, sans-serif;">android@Ubuntu:~$ strings /lib/x86_64-linux-gnu/libc.so.6 | grep GLIBC_ GLIBC_2.2.5 GLIBC_2.2.6 GLIBC_2.3 GLIBC_2.3.2 GLIBC_2.3.3 GLIBC_2.3.4 GLIBC_2.4 GLIBC_2.5 GLIBC_2.6 GLIBC_2.7 GLIBC_2.8 GLIBC_2.9 GLIBC_2.10 GLIBC_2.11 GLIBC_2.12 GLIBC_2.13 GLIBC_2.14 GLIBC_2.15 GLIBC_PRIVATE</span> |
找到gnu下的glibc的官网地址(http://ftp.gnu.org/gnu/libc/)。
找到2.17的版本。下载完后,解压,进入目录,编译,安装:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<span style="font-family: arial, helvetica, sans-serif;">android@Ubuntu:~$ tar xzvf glibc-2.17.tar.gz android@Ubuntu:~$ cd glibc-2.17/ android@Ubuntu:~/glibc-2.17$ ./configure checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking for gcc... gcc checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking for readelf... readelf configure: error: you must configure in a separate build directory</span> |
可以看到,系统给出了一个错误提示,说必须在另外一个独立的目录下执行configure命令。于是:
1 2 3 |
<span style="font-family: arial, helvetica, sans-serif;">android@Ubuntu:~/glibc-2.17$ mkdir build android@Ubuntu:~/glibc-2.17$ cd build android@Ubuntu:~/glibc-2.17/build$ ../configure --prefix=/opt/glibc-2.17</span> |
注意:这里的“–prefix=/opt/glibc-2.17”的作用是指定glibc的安装目录到opt目录下,目的是防止本次安装的glibc与系统中原来存在的其他版本冲突或者干扰。但是,这样安装之后,必须将该目录手动添加到系统的环境变量中去,否则其他程序将无法引用。
这下子可以走下去了。但是,好景不长,一会的工夫,又给出了一个错误提示:
1 2 3 4 5 6 7 8 9 10 11 12 |
<span style="font-family: arial, helvetica, sans-serif;">...... checking for gmsgfmt... no checking for msgfmt... msgfmt checking version of msgfmt... 0.18.1, ok checking for makeinfo... no checking for sed... sed checking version of sed... 4.2.1, ok checking for gawk... no checking for nm... nm configure: error: *** These critical programs are missing or too old: gawk *** Check the INSTALL file for required versions.</span> |
原来是缺少gawk工具。这也是一个很常用的工具,我系统中的版本太旧了,无法满足它的要求。找到gawk的官网进行下载(http://ftp.gnu.org/gnu/gawk/)。
找一个你认为合适的版本下载吧。我本人选的4.1.4的版本。
下载完后,解压,进入目录,编译,安装:
1 2 3 4 5 6 |
<span style="font-family: arial, helvetica, sans-serif;">android@Ubuntu:~$ cp /mnt/share/tmp/gawk-4.1.4.tar.gz gawk-4.1.4.tar.gz android@Ubuntu:~$ tar xvzf gawk-4.1.4.tar.gz android@Ubuntu:~$ cd gawk-4.1.4/ android@Ubuntu:~/gawk-4.1.4$ ./configure android@Ubuntu:~/gawk-4.1.4$ make android@Ubuntu:~/gawk-4.1.4$ sudo make install</span> |
一路顺畅,等待安装完毕之后。再回到glibc的目录下,重新执行configure的命令。这下成功了。然后顺序执行make和make install,直到全部完成。
题后话:
上文中介绍的方法,其实只是完成了对新版本glibc工具的安装,但是,装完并不代表能用,系统中可用的glibc环境仍然没有发生变化(因为系统的glibc环境比较棘手,我不敢去私自修改)。不过,暂时的失败并不代表完全没有办法,我决定先将这个过程记录在此,日后若有机会,再过来慢慢研究。
当然,若是各位看官有兴趣,大可以去百度一下,如何去修改系统的glibc环境,因为,毕竟还是有不少高人动手修改成功了。当然,这是冒着系统崩溃的风险来操作的。所以,各位量力而行吧~~~
以下答案是来自stackoverflow:
https://stackoverflow.com/questions/19471683/lib-libc-so-6-version-glibc-2-17-not-found
1.
Download 64 bit package from this site https://launchpad.net/ubuntu/raring/amd64/libc6/2.17-0ubuntu4
Install libc6 2.17 by the command ,
sudo dpkg -i libc6_2.17-0ubuntu4_amd64.deb
Cheers !
2.
This shell script worked for me: https://groups.google.com/forum/#!category-topic/beagleboard/oPq-Xt0TVdY
see the response from "A P" which is a script that installs a later version on the beaglebone black:
I am running a beaglebone black rev C with debian wheezy.
1 2 3 4 5 |
<span style="font-family: arial, helvetica, sans-serif;">#!/bin/sh echo "deb http://ftp.debian.org/debian sid main" >> /etc/apt/sources.list apt-get update apt-get -t sid install libc6 libc6-dev libc6-dbg echo "Please remember to hash out sid main from your sources list. /etc/apt/sources.list"</span> |