【发布时间】: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