Eclipse-CDT无法在NDK项目中找到stdlib符号

Dyl*_*kes 8 c++ eclipse android eclipse-cdt android-ndk

我正在尝试使用NDK和C++编写一个简单的Android应用程序.具体来说,我想使用最新版本的NDK(r7)中包含的gnustdc ++.JNI库已经编译并且作为C完美地工作,但是现在我正在尝试引入C++,我遇到了一些问题.

我已添加${NDK_ROOT}/sources/cxx-stl/gnu-libstdc++/include/到项目的包含路径,并且#includes内联已解决.但是,尝试实际使用任何STL类(例如vector)会导致Symbol 'vector' could not be resolved.

所有的进口标准C符号<stdlib.h>而这些工作为好,直到我尝试更换#include使用<cstdlib>.然后它失败了Function 'malloc' could not be resolved等等.

奇怪的是,添加stlport标头(in ${NDK_ROOT}/sources/cxx-stl/stlport/stlport)修复了我的所有问题.但是我在GNU C++中链接,而不是STLPort,因此这是一个不方便且不正确的"解决方案".看起来奇怪的是这些标题会起作用但其他标题不起作用.Eclipse无法索引或解析GNU C++标头吗?

Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := libfoobar-jni
LOCAL_SRC_FILES := foobar.cpp
LOCAL_LDLIBS := -llog -lGLESv2

LOCAL_C_INCLUDES := sources/cxx-stl/gnu-libstdc++/include/
LOCAL_CFLAGS := -g -std=c99

include $(BUILD_SHARED_LIBRARY)
Run Code Online (Sandbox Code Playgroud)

Application.mk

APP_STL := gnustl_shared
Run Code Online (Sandbox Code Playgroud)

编辑:我根据以下内容设置项目:

http://mhandroid.wordpress.com/2011/01/23/using-eclipse-for-android-cc-development/

cor*_*bin 3

阅读本文,它有解决方案:

http://comments.gmane.org/gmane.comp.handhelds.android.ndk/14371

以防有一天链接失效,摘要如下:

这是 gnustl_shared 模块声明中的一个错误。抱歉,该问题将在下一个版本中修复。同时,您可以手动更改$NDK/sources/cxx-stl/gnu-libstdc++/Android.mk和替换显示以下内容的行:

LOCAL_EXPORT_LDLIBS := $(LOCAL_PATH)/libs/$(TARGET_ARCH_ABI)/libsupc++.a
Run Code Online (Sandbox Code Playgroud)

和:

LOCAL_EXPORT_LDLIBS := $(call host-path,$(LOCAL_PATH)/libs/$(TARGET_ARCH_ABI)/libsupc++.a)
Run Code Online (Sandbox Code Playgroud)