在64位Ubuntu 12.04上运行aapt:加载共享库时出错:libc++.所以:没有这样的文件或目录

Running aapt on 64-bit Ubuntu 12.04: error while loading shared libraries: libc++.so: No such file or directory

本文关键字:所以 libc++ 文件 出错 Ubuntu 64位 运行 共享 加载 aapt      更新时间:2023-10-16

我下载了Android开源项目,并使用以下说明在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

这让我能够运行它,它起到了作用。有了安卓的最新版本,这已经不够了。我仍然得到libc++.so: cannot open shared object file message

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

$file/aosp/out/host/linux-x86/bin/aaptaapt: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

这个跑了。它还没有被剥离,所以共享的libs仍然嵌入其中。如果我剥离它:

$ 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.
相关文章: