我下载了Android Open Source Project,并按照以下说明在Linux(Ubuntu 12.04 64位)上构建了它:

http://source.android.com/source/building.html

我可以毫无问题地构建它。构建完成后,我对构建工具特别是aapt感兴趣。运行它时,我看到以下内容:

awt@aosp-build:/aosp/out/host/linux-x86/sdk/sdk/android-sdk_eng.awt_linux-x86/build-tools/android-5.0.50.50.50.50$ ./aapt
./aapt: error while loading shared libraries: libc++.so: cannot open shared object file: No such file or directory

所以,这很奇怪。特别是考虑到libc++。so就在同一目录中:
awt@aosp-build:/aosp/out/host/linux-x86/sdk/sdk/android-sdk_eng.awt_linux-x86/build-tools/android-5.0.50.50.50.50$ ls -l

-rwxrwxr-x 1 awt awt 1118633 Feb  4 19:42 aapt
-rwxrwxr-x 1 awt awt 1261036 Feb  4 19:42 libc++.so

$ file aapt
aapt: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, not stripped
$ file libc++.so
libc++.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, not stripped

我已经构建并使用了较旧的Android版本的构建工具,最后一个是4.3。要运行该程序,我需要:
$ sudo apt-get install ia32-libs

那使我可以运行它,并且它起作用了。有了Android的最新版本,这已经远远不够。我仍然得到libc++.so: cannot open shared object file message

out目录中还有aapt的其他中间版本。例如,这一个:

$文件/ aosp / out / host / linux-x86 / bin / aapt
aapt:ELF 32位LSB共享对象,Intel 80386,版本1(SYSV),动态链接(使用共享库),用于GNU / Linux 2.6.24,未剥离
$ ls -l / aosp / out / host / linux-x86 / bin / aapt
-rwxrwxr-x 1 awt awt 6978260 2月4日17:50 aapt

这一个运行。它尚未被剥离,因此共享库仍嵌入其中。如果我剥离它:
$ strip -s aapt
$ ./aapt
./aapt: error while loading shared libraries: libc++.so: cannot open shared object file: No such file or directory

然后,我们回到开始的地方。我怎样做才能使剥离后的版本像以前一样运行?

最佳答案

这是一个比较老的问题,但是最近对它的支持使我想起了我的解决方案。

答案是将libc++。so的位置附加到当前LD_LIBRARY_PATH:

$ export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/path/to/libc++.so
$ ./aapt -version
Android Asset Packaging Tool

Usage:
   aapt l[ist] [-v] [-a] file.{zip,jar,apk}
   List contents of Zip-compatible archive.

关于android - 在64位Ubuntu 12.04上运行aapt:加载共享库时出错:libc++。so:没有这样的文件或目录,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28335977/

10-11 14:26