gpt4 book ai didi

android - 使用独立工具链 android arm 构建 native 库

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:33:52 24 4
gpt4 key购买 nike

我正在尝试将 libraw 构建为 Android 共享库。看起来这个库太复杂了,无法与 Android.mk 等一起使用,或者更好:我还没有能力这样做。

我尝试使用 NDK 中的独立工具链,但在编译这个库时遇到了问题。

这是我编译lib的路径。如果我犯了明显的错误,请指出:

  1. 我下载了 ndk。
  2. 运行:make-standalone-toolchain.sh
  3. 将该独立工具链的 bin 文件夹添加为我的 PATH 中的第一项。
  4. 使用 --host=arm-linux-androideabi 运行 ./configure。这成功了
  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 32 位)。

当我查看为 Android ( here ) 构建 GDAL 的说明时,它使用了 LIBS="-lsupc++ -lstdc++" 的附加设置。这链接了 STL 和 C++ 异常?但是,当我在运行 configure 之前设置它们时,我会立即收到如下错误:

configure:3018: checking whether the C++ compiler worksconfigure: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

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

最佳答案

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

更好的方法是使用 Android.mk 文件并使用 ndk-build 编译它。

关于android - 使用独立工具链 android arm 构建 native 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8606044/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com