简体   繁体   English

使用STL和Android NDK C ++

[英]Using the STL with Android NDK C++

I am trying to use the STL in an Android NDK C++ File. 我试图在Android NDK C ++文件中使用STL。 I try to use map, vector and various other stl classes and I cannot compile it because it doesn't find the files. 我尝试使用map,vector和各种其他stl类,我无法编译它,因为它找不到文件。

My classes header starts with: 我的类标题以:

#pragma once
#include <map>
#include <iostream>
#include <stdexcept>
#include <vector>
#include <set>
#include <list>
#include <algorithm>

and I get following error messages: 我收到以下错误消息:

2>  In file included from jni/../../Classes/Assist/Test.cpp:1:
2>  jni/../../Classes/Assist/Test.h:2:15: error: map: No such file or directory
2>  jni/../../Classes/Assist/Test.h:3:20: error: iostream: No such file or directory
2>  jni/../../Classes/Assist/Test.h:4:21: error: stdexcept: No such file or directory
2>  jni/../../Classes/Assist/Test.h:5:18: error: vector: No such file or directory
2>  jni/../../Classes/Assist/Test.h:6:15: error: set: No such file or directory
2>  jni/../../Classes/Assist/Test.h:7:16: error: list: No such file or directory
2>  jni/../../Classes/Assist/Test.h:8:21: error: algorithm: No such file or directory
2>  In file included from jni/../../Classes/Assist/Test.cpp:1:

I read various posts and tried "APP_STL := stlport_static" and "APP_STL := gnustl_static" in an application.mk file but it didn't work. 我阅读了各种帖子并在application.mk文件中尝试了“APP_STL:= stlport_static”和“APP_STL:= gnustl_static”,但它没有用。

Does anyone know how I can get this to work ? 有谁知道我怎么能让这个工作?

I had the same problem, and then realized that I need to put: APP_STL := stlport_static 我有同样的问题,然后意识到我需要把:APP_STL:= stlport_static

in Application.mk, not Android.mk ... doh 在Application.mk中,而不是Android.mk ... doh

Then I needed to add: ${ANDROID_NDK_ROOT}\\sources\\cxx-stl\\stlport\\stlport 然后我需要添加:$ {ANDROID_NDK_ROOT} \\ sources \\ cxx-stl \\ stlport \\ stlport

to the include paths in eclipse to make it not complain in the UI about errors 在eclipse中包含路径,使其不会在UI中抱怨错误

It seems that the mistake was a somehow broken NDK. 似乎错误是某种程度上破坏了NDK。 I reinstalled it (delete, unzip) and now it works. 我重新安装它(删除,解压缩),现在它的工作原理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM