【问题标题】:Android NDK: iostream file not foundAndroid NDK:找不到 iostream 文件
【发布时间】:2019-02-04 11:57:54
【问题描述】:

我已经尝试了很多关于这个问题的建议,但似乎都没有解决我的问题。

这是我作为命令给出的:

 C:\Users\{name}\Desktop\MyApplication\libraries\tess-two-master\tess-two\jni> C:\Users\{name}\AppData\Local\Android\Sdk\android-ndk-r19\ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk

我无法编译 com_googlecode_tesseract_android/./src/api/baseapi.cpp 它给了我这个错误:

Android NDK: WARNING:com_googlecode_tesseract_android/Android.mk:tess: non-system libraries in linker flags: -latomic
Android NDK:     This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK:     or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK:     current module

com_googlecode_tesseract_android/./src/api/baseapi.cpp:45:10: fatal error
    'iostream' file not found
#include <iostream>
     ^~~~~~~~~~
1 error generated.
make: *** [obj/local/arm64-v8a/objs/tess/./src/api/baseapi.o] Error 1

这是我的 Application.mk

    APP_STL:= c++_shared
    APP_ABI := armeabi-v7a x86 arm64-v8a x86_64
    APP_OPTIM := release
    APP_PLATFORM := android-16
    APP_CPPFLAGS += -fexceptions -frtti
    NDK_TOOLCHAIN_VERSION := clang

这是我的 Android.mk

     LOCAL_PATH := $(call my-dir)
     TESSERACT_PATH := $(LOCAL_PATH)/com_googlecode_tesseract_android/src
     LEPTONICA_PATH := $(LOCAL_PATH)/com_googlecode_leptonica_android/src
     LIBJPEG_PATH := $(LOCAL_PATH)/libjpeg
     LIBPNG_PATH := $(LOCAL_PATH)/libpng

     # Just build the Android.mk files in the subdirs
     include $(call all-subdir-makefiles)

baseapi.cpp 中的所有 4 个标头都显示相同的错误 -

#include <iostream>
#include <string>
#include <iterator>
#include <fstream>

如果有人能帮我找出问题所在,那就太好了。谢谢。

PS:我正在使用 NDK r19

【问题讨论】:

  • platforms/android-16 中没有arch-arm64 目录。至少不在我安装的 NDK 中。它仅适用于android-21 及更高版本的平台。
  • @Michael 除了 APP_STL 之外,我没有更改任何内容。我是直接从官网下载的。
  • @Michael ndk-build 知道这一点,并且会为 64 位 ABI 上拉至 21。
  • 您可以简单地将#ifdef __cplusplus #endif 包含在您遇到此问题的所有头文件中。 __cplusplus 将为通过 C++ 编译器运行的任何编译单元定义。它真的很好用。 :)

标签: android android-ndk tesseract tess-two


【解决方案1】:

在这种情况下,您的 ndk-build 不会自动加载 Application.mk 文件。您必须明确指定它:

…ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk NDK_APPLICATION_MK=./Application.mk

或者您可以从 tess-two 目录(jni 上面的那个)运行ndk-build。在这种情况下,ndk-build 将找到两个 .mk 文件,您无需指定 NDK_PROJECT_PATH

…ndk-build

唯一的区别是输出(objlibs 目录)将在附近创建,而不是在 jni 目录中。 p>

【讨论】:

    猜你喜欢
    • 2011-06-03
    • 2018-05-16
    • 1970-01-01
    • 1970-01-01
    • 2020-02-10
    • 1970-01-01
    • 1970-01-01
    • 2012-02-26
    • 2021-08-25
    相关资源
    最近更新 更多