【问题标题】:Which compiler to use when running ndk-build on mupdf for OSX?在 OSX 的 mupdf 上运行 ndk-build 时使用哪个编译器?
【发布时间】:2016-09-19 20:10:51
【问题描述】:

我想在我的 Android Studio 项目中使用 mudf 来查看/编辑 PDF 文件,我正在按照http://www.mupdf.com/docs/how-to-build-mupdf-for-android 的说明进行操作。我已经正确设置了 SDK 和 NDK,并且将 local.properties 文件配置为指向正确的相应路径。现在,当我运行 ndk-build 时,我得到以下输出:

    armeabi-v7a] Compile thumb  : mupdfthirdparty <= cff.c
    [armeabi-v7a] Compile thumb  : mupdfthirdparty <= type1cid.c
    [armeabi-v7a] Compile thumb  : mupdfthirdparty <= psaux.c
    [armeabi-v7a] Compile thumb  : mupdfthirdparty <= pshinter.c
    [armeabi-v7a] Compile thumb  : mupdfthirdparty <= psnames.c
    [armeabi-v7a] Compile thumb  : mupdfthirdparty <= raster.c
    [armeabi-v7a] Compile thumb  : mupdfthirdparty <= smooth.c
    [armeabi-v7a] Compile thumb  : mupdfthirdparty <= sfnt.c
    [armeabi-v7a] Compile thumb  : mupdfthirdparty <= truetype.c
    [armeabi-v7a] Compile thumb  : mupdfthirdparty <= type1.c
    [armeabi-v7a] StaticLibrary  : libmupdfthirdparty.a
    [armeabi-v7a] SharedLibrary  : libmupdf_java.so
    /Users/aayushkothari/Codes/mupdf/platform/android/viewer/jni/../../../../source/fitz/printf.c:29: error: undefined reference to '__isinff'
    /Users/aayushkothari/Codes/mupdf/platform/android/viewer/jni/../../../../thirdparty/mujs/jsdate.c:332: error: undefined reference to '__isfinite'
    /Users/aayushkothari/Codes/mupdf/platform/android/viewer/jni/../../../../thirdparty/mujs/jsdate.c:227: error: undefined reference to '__isfinite'
    /Users/aayushkothari/Codes/mupdf/platform/android/viewer/jni/../../../../thirdparty/mujs/jsparse.c:869: error: undefined reference to '__isfinite'
    /Users/aayushkothari/Codes/mupdf/platform/android/viewer/jni/../../../../thirdparty/mujs/jsdate.c:318: error: undefined reference to '__isfinite'
    /Users/aayushkothari/Codes/mupdf/platform/android/viewer/jni/../../../../thirdparty/mujs/jsnumber.c:40: error: undefined reference to '__isinf'
    /Users/aayushkothari/Codes/mupdf/platform/android/viewer/jni/../../../../thirdparty/mujs/json.c:107: error: undefined reference to '__isinf'
    /Users/aayushkothari/Codes/mupdf/platform/android/viewer/jni/../../../../thirdparty/mujs/jsvalue.c:14: error: undefined reference to '__isinf'
    /Users/aayushkothari/Codes/mupdf/platform/android/viewer/jni/../../../../thirdparty/mujs/jsvalue.c:226: error: undefined reference to '__isinf'
    collect2: error: ld returned 1 exit status
    make: *** [/Users/aayushkothari/Codes/mupdf/platform/android/viewer/obj/local/armeabi-v7a/libmupdf_java.so] Error 1

根据How to set standard c99 for compile android NDK project 的答案,我修改了我的Application.mk 文件以包含APP_CFLAGS += -std=c99

当我再次运行 ndk-build 时,我得到以下信息:

[armeabi-v7a] Compile thumb  : mupdf_java <= mupdf.c
/Users/aayushkothari/Codes/mupdf/platform/android/viewer/jni/mupdf.c: In function 'Java_com_artifex_mupdfdemo_MuPDFCore_getFocusedWidgetSignatureState':
/Users/aayushkothari/Codes/mupdf/platform/android/viewer/jni/mupdf.c:2361:2: warning: implicit declaration of function 'pdf_signatures_supported' [-Wimplicit-function-declaration]
  if (!pdf_signatures_supported())
  ^
[armeabi-v7a] Compile thumb  : mupdfcore <= bbox-device.c
[armeabi-v7a] Compile thumb  : mupdfcore <= bidi-std.c
[armeabi-v7a] Compile thumb  : mupdfcore <= bidi.c
[armeabi-v7a] Compile thumb  : mupdfcore <= bitmap.c
[armeabi-v7a] Compile thumb  : mupdfcore <= buffer.c
[armeabi-v7a] Compile thumb  : mupdfcore <= colorspace.c
/Users/aayushkothari/Codes/mupdf/platform/android/viewer/jni/../../../../source/fitz/colorspace.c: In function 'fast_cmyk_to_rgb_ARM':
/Users/aayushkothari/Codes/mupdf/platform/android/viewer/jni/../../../../source/fitz/colorspace.c:410:2: error: 'asm' undeclared (first use in this function)
  asm volatile(
  ^
/Users/aayushkothari/Codes/mupdf/platform/android/viewer/jni/../../../../source/fitz/colorspace.c:410:2: note: each undeclared identifier is reported only once for each function it appears in
/Users/aayushkothari/Codes/mupdf/platform/android/viewer/jni/../../../../source/fitz/colorspace.c:410:6: error: expected ';' before 'volatile'
  asm volatile(
      ^
make: *** [/Users/aayushkothari/Codes/mupdf/platform/android/viewer/obj/local/armeabi-v7a/objs/mupdfcore/__/__/__/__/source/fitz/colorspace.o] Error 1

经过一番搜索,我将 -c99 更改为 -gnu99 并再次运行 ndk-build,但再次出现初始错误。

我需要更改/添加什么来摆脱这些,以及一般来说,Android 新手应该遵循哪些步骤将 muPDF 包含在现有的 Android Studio 项目中?

【问题讨论】:

    标签: android android-studio android-ndk mupdf


    【解决方案1】:

    关于 __isinff 等的第一个问题是我认为 64 位 android NDK 的一个已知问题,或者至少与 Google 故意对 NDK 进行的一些更改有关。

    如果您恢复到较旧的 32 位 ndk,它应该可以工作 - 例如:

    http://dl.google.com/android/ndk/android-ndk-r10d-darwin-x86.bin

    将此添加到您的 Application.mk 也可能会有所帮助:

    APP_PLATFORM := android-9
    

    参见,例如,https://groups.google.com/forum/#!topic/android-ndk/L2gc5HRq_dA

    【讨论】:

    • 根据您的建议,我将 Application.mk 中的 android-8 更改为 android-9 并且有效。谢谢你,@JosephH。
    猜你喜欢
    • 1970-01-01
    • 2014-08-04
    • 2011-09-29
    • 1970-01-01
    • 2015-02-15
    • 2012-12-19
    • 2012-08-30
    • 2015-01-29
    • 2010-10-07
    相关资源
    最近更新 更多