使用独立工具链android arm构建本机库 [英] Building native library with standalone toolchain android arm

查看:108
本文介绍了使用独立工具链android arm构建本机库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

我尝试了使用来自NDK的独立工具链的方法,但是在编译此lib时遇到了麻烦.

I tried the route of using a standalone toolchain from the NDK, but I am getting stuck when compiling this lib.

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

This is the path I take to compile the lib. Please point out if I am making obvious errors:

  1. 我下载了ndk.
  2. 运行:make-standalone-toolchain.sh
  3. 将该独立工具链的bin文件夹添加为我的PATH中的第一项.
  4. ./configure--host=arm-linux-androideabi一起运行.成功
  5. make,在这里它崩溃得非常快.
  1. I downloaded the ndk.
  2. ran: make-standalone-toolchain.sh
  3. Added the bin folder of that standalone toolchain as first item in my PATH.
  4. Ran ./configure with --host=arm-linux-androideabi. This succeeded
  5. 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=\"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上是否有用,但是我想知道是否应该应用一些其他标志或配置来使其正常工作?

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?

请注意,如果仅针对我的系统进行编译而无需交叉编译,那么我就能成功编译该lib. (Linux 32位).

Note that I am able to compile this lib succesfully if just compiling for my system without crosscompiling. (linux 32bit).

当我正在寻找有关为Android构建GDAL的说明(此处)时,它使用LIBS="-lsupc++ -lstdc++"的附加设置.这链接了STL和C ++异常吗? 但是,当我在运行configure之前进行设置时,会立即收到类似以下错误:

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?

推荐答案

我必须添加swab函数的实现,因为NDK没有该实现. 之后,这个编译的很好(但是我使用了crystax ndk).

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).

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

A better way toolwise was to just use a Android.mk file and use ndk-build to compile it.

这篇关于使用独立工具链android arm构建本机库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆