Android NDK源编译&构建成功 - 但功能'to_string'无法在Eclipse IDE中解决 [英] Android NDK Source Compiled & Build Successfully - But Function 'to_string' could not be resolved in Eclipse IDE

查看:670
本文介绍了Android NDK源编译&构建成功 - 但功能'to_string'无法在Eclipse IDE中解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索了如何在android ndk中使用to_string()。经过长时间的搜索,从此链接,我更改了应用程序。 mk文件说。并且cpp源编译并仅从终端构建。

 终端输出:
> ndk-build
Android NDK:警告:APP_PLATFORM android-21大于android:minSdkVersion 9 in
/< some path> /Android/Exercise01/AndroidManifest.xml
[armeabi-v7a ]安装:libndkfoo.so => libs / armeabi / libndkfoo.so

但是在ecplise IDE中,仍然会收到错误功能 to_string'无法解决。所以从IDE我无法运行android应用程序。 (注意:在使用std :: to_string之前,源编译正确)



我试图将头文件包含如下(下)项目属性 - > C / C ++通用 - >路径和符号 - > GNU C ++)



vstring.h from // android-ndk-r10d / sources / cxx-stl /gnu-libstdc++/4.9/include/ext

&

basic_string.h from //android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.9/



但没有运气b $ b

  LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_LDLIBS:= -llog
TARGET_PLATFORM:= android-21
TARGET_ARCH_ABI:= armeabi-v7a
TARGET_ABI:= android-21-armeabi-v7a#上面两个变量的连接
#这里给出我们的模块名称和源文件
LOCAL_MODULE:= ndkfoo
LOCAL_C_INCLUDES:= $(LOCAL_PATH)/ header
LOCAL_SRC_FILES:= src / NativeFunction.cpp src / clsArithmeticParser.cpp
include $(BUILD_SHAR ED_LIBRARY)

Application.mk

  #APP_STL:= stlport_static 
APP_STL:= c ++ _ static



我知道,我做了一些小错误,但是不能找到很长时间。



已编辑:

我可以使用std :: to_string& std :: stoll通过eclipse在下面的技巧。这些可以帮助一些在罕见的情况下。所以添加这一点来测试c ++ 11支持通过eclipse IDE。仅在源文件或头文件打开时显示错误。只需关闭开源文件文件(.h,.c,.cpp)。关闭并重新打开日食。现在可以通过android模拟器编译和运行了。

解决方案

在引用@Khaled Lakehal的答案后,我自己发布了我的问题的答案。希望这可以帮助某人。



按照以下步骤进行操作:


  1. 更新eclipse版本从Luna到最新的火星2

  2. 使用 - > import - >将旧版本的eclipse
    导入到现有项目中将现有的Android代码导入Workspace

  3. 导入后C / C ++项目转换有一些问题。所以按照这个链接以撤销C / C ++项目转换

  4. 将项目转换为新的C / C ++。

  5. 要删除错误,我引用了这个链接,并选择了使用构建运行

  6. 关闭&重新打开IDE

所以现在可以使用std :: to_string& std :: stoll函数。


I searched how to use to_string() in android ndk. After a long search, from this link, i changed the Application.mk file as said. And the cpp source compiled and build properly only from the terminal.

        Terminal output :
         > ndk-build
        Android NDK: WARNING: APP_PLATFORM android-21 is larger than android:minSdkVersion 9 in        
/<some path>/Android/Exercise01/AndroidManifest.xml    
    [armeabi-v7a] Install        : libndkfoo.so => libs/armeabi/libndkfoo.so

But in ecplise IDE, still i am getting error as "Function 'to_string' could not be resolved". So from the IDE i am not able to run the android application. (Note : before the usage of std::to_string, the source compiled properly)

I tried to include the header files as below (under project properties->C/C++ general->Path and Symbols->GNU C++)

vstring.h from //android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.9/include/ext
&
basic_string.h from //android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.9/include/bits

But no luck.

Androi.mk File

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_LDLIBS    := -llog
TARGET_PLATFORM := android-21
TARGET_ARCH_ABI := armeabi-v7a
TARGET_ABI := android-21-armeabi-v7a # concatenation of above two variables
# Here we give our module name and source file(s)
LOCAL_MODULE    := ndkfoo
LOCAL_C_INCLUDES := $(LOCAL_PATH)/header
LOCAL_SRC_FILES := src/NativeFunction.cpp src/clsArithmeticParser.cpp
include $(BUILD_SHARED_LIBRARY)

Application.mk

#APP_STL := stlport_static
APP_STL:=c++_static       

I know, i am doing some small mistake, but not able to find for a long time. Any solution/suggestion appreciated.

Edited :
I am able use the std::to_string & std::stoll through eclipse in the below trick only. These can help some one in rare situation. So adding this point to test the c++11 support through eclipse IDE. The error shown only when the source file or the header file opened. Just close open source file documents (.h, .c, .cpp). Close and reopen the eclipse. Now it is ready to compile and run through the android emulator.

解决方案

After referring the answer by @Khaled Lakehal, I myself posting this answer for my question.Hope this may help someone.

Followed the below step to make it work:

  1. Update the eclipse version from Luna to latest Mars 2
  2. Imported the existing project from the old version of the eclipse using -> import -> Existing Android code into Workspace
  3. Had some problem with the C/C++ project conversion after import. So followed this link to undo the C/C++ project conversion
  4. Converted the project to C/C++ newly.
  5. To remove the error, I referred this link, and selected the "Run with build" only
  6. Close & Reopen the IDE

So now able to use the std::to_string & std::stoll functions.

这篇关于Android NDK源编译&amp;构建成功 - 但功能'to_string'无法在Eclipse IDE中解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆