2011-12-22 63 views
5

我想建立作为Android共享库的图书馆。它看起来像lib是太复杂Android.mk等使用,或更好:我不能够做到这一点。建立与独立工具链Android手臂的本机库

我试过从NDK使用独立工具链的路线,但是编译这个库的时候遇到了问题。

这是我编译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=\"[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 

我怀疑此错误信息是有益的,在这里计算器,但我在想,如果我已经申请了一些额外的标志或配置来得到这个工作?

请注意,如果只是在没有交叉编译的情况下编译我的系统,我能够成功编译此库。 (linux 32bit)。

当我正在寻找构建Android GDAL的指令(here)时,它使用了另外的设置LIBS="-lsupc++ -lstdc++"。这链接STL和C++异常?

 
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 

所以,我有点卡住: 然而,当我运行前设置这些我configure我立刻喜欢出现错误。有人想法?

回答

4

我不得不添加一个swab函数的实现,因为NDK没有那个。 之后,这编译好(但我使用crystaxndk)。

更好的工具方法是只使用Android.mk文件并使用ndk-build进行编译。

+0

嗨@Peterdk你能告诉我你在哪里得到了拭子功能的实现吗?或者你自己写了吗? – asloob 2013-06-07 10:11:33

+0

嗨,我想我只是用它搜索的。我没有自己写。也许还可以结合搜索crystax。 – Peterdk 2013-06-07 13:46:34

+0

谢谢!我找到了。 – asloob 2013-06-08 10:56:42

2

来自问题底部的链接错误是由于来自NDK r7的make-standalone-toolchain.sh创建了不完整的工具链(它遗漏了一些库,包括libsupc++.a)。我建议你尝试从以前的NDK版本之一制作工具链(r6b应该没问题)。