NDK - 的Andr​​oid的Java与本地(JNI)C ++ code编译问题

问题描述:

我使用Java和本机JNI C ++ code的组合为Android项目,在OSX使用NDK R8B,在Eclipse中。我希望能够在STD命名空间中使用常规的C ++类(地图,字符串)。

I am using a mix of Java and native JNI C++ code for an android project, using NDK r8b, in Eclipse in OSX. I want to be able to use the regular C++ classes (map, string) in std namespace.

在Android.mk文件中加入:

In the Android.mk file the following were added:

APP_STL:= stlport_shared

APP_STL := stlport_shared

在这里,我也试过静态库。请参阅 http://docs.huihoo.com/android/ndk/r5 /CPLUSPLUS-SUPPORT.html

Here I also tried static library. Refer to http://docs.huihoo.com/android/ndk/r5/CPLUSPLUS-SUPPORT.html

STLPORT_FORCE_REBUILD:= TRUE

STLPORT_FORCE_REBUILD := true

也试图消除强迫构建。

在C / C ++的路径和变量:

In the C/C++ path and variables:

$ {} NDKROOT /来源/ CXX-STL / STLport的/ STLport的

${NDKROOT}/sources/cxx-stl/stlport/stlport

地图,并列入.cpp文件串标头。我能够使用std :: string的和std ::地图。助理他们拿起。当(在Eclipse F3)搜索的定义头文件所示,即解决了。此外,大纲显示串和地图头文件,并双击他们的时候也带来了头的前列。

"map" and "string" headers were included in the .cpp file. I am able to use std::string and std::map. The assistant picks up on them. When searching for the definition (F3 in eclipse) the header file is shown, i.e. resolved. Also, the outline shows the "string" and "map" header files and when double clicking them it also brings the headers to the forefront.

不过,版本不接他们回家。我得到以下几点:

However, the build doesn't pick them up. I get the following:

> ndk-build
> Gdbserver      : [arm-linux-androideabi-4.6] libs/armeabi/gdbserver
> Gdbsetup       : libs/armeabi/gdb.setup
> Gdbserver      : [arm-linux-androideabi-4.6] libs/armeabi-v7a/gdbserver
> Gdbsetup       : libs/armeabi-v7a/gdb.setup
> Compile++ arm    : ImageTargets <= ImageTargets.cpp
> xxx/Project/Code/MyImageTarget/jni/ImageTargets.cpp:20:18: fatal error: string: No such file > or directory
> compilation terminated.
> make: *** [xxx/Project/Code/MyImageTarget/obj/local/armeabi/objs->    debug/ImageTargets/ImageTargets.o] Error 1

有没有人任何想法还有其它的东西去尝试。

Has anyone any idea what else is there to try.

使用 V = 1的 参数NDK的构建命令行。这将呼应所有执行的命令,包括编译和链接,用自己的所有参数NDK建立受让人。

Use V=1 parameter on ndk-build command line. This will echo all executed commands, including compilation and link, with all their parameters that NDK build assigns.

在你的情况,答案可以在不建立详细的日志中找到:

In your case, the answer can be found without detailed build log:

在Android.mk文件中加入:

In the Android.mk file the following were added:

APP_STL:= stlport_shared

这是你的错误。你引用的文件解释说,这设置应进入 Application.mk 。这个文件通常被认为是可选的。是的。而不是创建这个文件,你可以指定 APP_STL 在命令行上:

This is your mistake. The document you cited explains that this setting should go into Application.mk. This file is usually considered optional. Yes it is. Instead of creating this file, you can specify APP_STL on the command line:

ndk-build V=1 APP_STL=stlport_static

我不知道为什么,并解决如何使用Eclipse 的#include&LT;字符串方式&gt; 地图