使用独立工具链 android arm 构建本机库
我正在尝试将 libraw 构建为 Android 共享库。看起来这个库太复杂,无法与 Android.mk 等一起使用,或者更好:我还没有能力做到这一点。
我尝试了使用 NDK 中的独立工具链的路线,但在编译此库时遇到了困难。
这是我编译库所采用的路径。如果我犯了明显的错误,请指出:
- 我下载了 ndk。
- 运行:
make-standalone-toolchain.sh
- 将该独立工具链的
bin
文件夹添加为我的PATH
中的第一项。 - 使用
--host=arm-linux-androideabi
运行./configure
。这成功了 - Ran
make
,这里它崩溃得非常快。
LibRaw-0.14.4$ make depbase=`echo internal/dcraw_common.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\ /bin/bash ./libtool --tag=CXX --mode=compile arm-linux-androideabi-g++ -DPACKAGE_NAME=\"LibRaw\" -DPACKAGE_TARNAME=\"libraw\" -DPACKAGE_VERSION=\"0.14.4\" -DPACKAGE_STRING=\"LibRaw\ 0.14.4\" -DPACKAGE_BUGREPORT=\"[email protected]\" -DPACKAGE_URL=\"http://www.libraw.org\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -I. -I/usr/local/include -g -O2 -MT internal/dcraw_common.lo -MD -MP -MF $depbase.Tpo -c -o internal/dcraw_common.lo internal/dcraw_common.cpp &&\ mv -f $depbase.Tpo $depbase.Plo libtool: compile: arm-linux-androideabi-g++ -DPACKAGE_NAME=\"LibRaw\" -DPACKAGE_TARNAME=\"libraw\" -DPACKAGE_VERSION=\"0.14.4\" "-DPACKAGE_STRING=\"LibRaw 0.14.4\"" -DPACKAGE_BUGREPORT=\"[email protected]\" -DPACKAGE_URL=\"http://www.libraw.org\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -I. -I/usr/local/include -g -O2 -MT internal/dcraw_common.lo -MD -MP -MF internal/.deps/dcraw_common.Tpo -c internal/dcraw_common.cpp -fPIC -DPIC -o internal/.libs/dcraw_common.o internal/dcraw_common.cpp: In member function 'void LibRaw::read_shorts(ushort*, int)': internal/dcraw_common.cpp:119: error: 'swab' was not declared in this scope internal/dcraw_common.cpp: In member function 'void LibRaw::write_ppm_tiff()': internal/dcraw_common.cpp:9235: error: 'swab' was not declared in this scope make: *** [internal/dcraw_common.lo] Error 1
我怀疑这个错误消息在 stackoverflow 上是否有帮助,但我想知道是否应该应用一些额外的标志或配置来使其正常工作?
请注意,如果仅针对我的系统进行编译而不进行交叉编译,我就能够成功编译此库。 (Linux 32 位)。
当我寻找为 Android 构建 GDAL 的说明时(此处),它使用LIBS="-lsupc++ -lstdc++"
的附加设置。这将STL 和C++ 异常联系起来吗? 但是,当我在运行 configure
之前设置这些内容时,我立即收到如下错误:
configure:3018: checking whether the C++ compiler works configure:3040: arm-linux-androideabi-g++ conftest.cpp -lsupc++ -lstdc++ >&5 /tmp/android-chain/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: cannot find -lsupc++ collect2: ld returned 1 exit status
所以,我有点卡住了。有人出主意吗?
I am trying to build libraw as a Android shared library. It looks the lib is too complex to use with Android.mk etc, or better: I am not capable yet of doing that.
I tried the route of using a standalone toolchain from the NDK, but I am getting stuck when compiling this lib.
This is the path I take to compile the lib. Please point out if I am making obvious errors:
- I downloaded the ndk.
- ran:
make-standalone-toolchain.sh
- Added the
bin
folder of that standalone toolchain as first item in myPATH
. - Ran
./configure
with--host=arm-linux-androideabi
. This succeeded - Ran
make
, here it crashed very fast.
LibRaw-0.14.4$ make depbase=`echo internal/dcraw_common.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\ /bin/bash ./libtool --tag=CXX --mode=compile arm-linux-androideabi-g++ -DPACKAGE_NAME=\"LibRaw\" -DPACKAGE_TARNAME=\"libraw\" -DPACKAGE_VERSION=\"0.14.4\" -DPACKAGE_STRING=\"LibRaw\ 0.14.4\" -DPACKAGE_BUGREPORT=\"[email protected]\" -DPACKAGE_URL=\"http://www.libraw.org\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -I. -I/usr/local/include -g -O2 -MT internal/dcraw_common.lo -MD -MP -MF $depbase.Tpo -c -o internal/dcraw_common.lo internal/dcraw_common.cpp &&\ mv -f $depbase.Tpo $depbase.Plo libtool: compile: arm-linux-androideabi-g++ -DPACKAGE_NAME=\"LibRaw\" -DPACKAGE_TARNAME=\"libraw\" -DPACKAGE_VERSION=\"0.14.4\" "-DPACKAGE_STRING=\"LibRaw 0.14.4\"" -DPACKAGE_BUGREPORT=\"[email protected]\" -DPACKAGE_URL=\"http://www.libraw.org\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -I. -I/usr/local/include -g -O2 -MT internal/dcraw_common.lo -MD -MP -MF internal/.deps/dcraw_common.Tpo -c internal/dcraw_common.cpp -fPIC -DPIC -o internal/.libs/dcraw_common.o internal/dcraw_common.cpp: In member function 'void LibRaw::read_shorts(ushort*, int)': internal/dcraw_common.cpp:119: error: 'swab' was not declared in this scope internal/dcraw_common.cpp: In member function 'void LibRaw::write_ppm_tiff()': internal/dcraw_common.cpp:9235: error: 'swab' was not declared in this scope make: *** [internal/dcraw_common.lo] Error 1
I doubt this error message is helpfull here at stackoverflow, but I am left wondering if I should have applied some additional flags or configuration to get this to work?
Note that I am able to compile this lib succesfully if just compiling for my system without crosscompiling. (linux 32bit).
When I am looking to a instruction for building GDAL for Android (here), it uses a additional setting of LIBS="-lsupc++ -lstdc++"
. This links the STL and C++ exceptions?
However, when I set those before running my configure
I get immediately errors like:
configure:3018: checking whether the C++ compiler works configure:3040: arm-linux-androideabi-g++ conftest.cpp -lsupc++ -lstdc++ >&5 /tmp/android-chain/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: cannot find -lsupc++ collect2: ld returned 1 exit status
So, I am a bit stuck. Someone an idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我必须添加 swab 函数的实现,因为 NDK 没有该函数。
后来编译得很好(但我使用了crystax ndk)。
更好的工具方法是仅使用
Android.mk
文件并使用ndk-build
来编译它。I had to add an implementation of the
swab
function, since the NDK does not have that one.Afterwards this compiled fine (but I used the crystax ndk).
A better way toolwise was to just use a
Android.mk
file and usendk-build
to compile it.出现问题底部的链接器错误是因为 NDK r7 中的
make-standalone-toolchain.sh
创建了不完整的工具链(它缺少一些库,包括libsupc++.a
)。我建议您尝试从以前的 NDK 版本之一创建工具链(r6b 应该没问题)。Linker error from the bottom of your question occurs because
make-standalone-toolchain.sh
from NDK r7 creates incomplete toolchain (it misses some libraries includinglibsupc++.a
). I recommend you try making a toolchain from one of previous NDK releases (r6b should be fine).