使用独立工具链android arm构建本机库

Pet*_*rdk 5 android cross-compiling toolchain android-ndk

我正在尝试将libraw构建为Android共享库.看起来lib太复杂了,无法与Android.mk等一起使用,或者更好:我无法做到这一点.

我尝试了使用NDK中的独立工具链的路线,但是在编译这个lib时我遇到了困难.

这是我编译lib的路径.请指出我是否犯了明显的错误:

  1. 我下载了ndk.
  2. 跑: make-standalone-toolchain.sh
  3. 添加了bin独立工具链的文件夹作为我的第一项PATH.
  4. ./configure--host=arm-linux-androideabi.这成功了
  5. 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=\"info@libraw.org\" -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=\"info@libraw.org\" -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 32bit).

当我正在寻找构建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

所以,我有点卡住了.有人有想法吗?

Pet*_*rdk 4

我必须添加该swab函数的实现,因为 NDK 没有该函数。后来编译得很好(但我使用了crystax ndk)。

更好的工具方式是只使用一个Android.mk文件并使用ndk-build它来编译它。