开发者

Fixing Eclipse errors when using Android NDK and std::vector

I'm using eclipse to develop an android app that also uses the ndk. I vectors in my app and I've done the necessary stuff to get them by including

APP_STL := stlport_static

In my Application.mk

Everything is working fine it compiles and runs but Eclipse keeps gi开发者_如何学运维ving me errors when I use the vectors

std::vector<int> blah

for example creates an error. If I delete the error and keep going it compiles and runs fine.

I've added ${NDKROOT}/sources/cxx-stl/gnu-libstdc++/include

In my project config under C++ General -> Paths and Symbols -> include

It resolves #include <vector> fine (before I added the path above I had an error for this) but I still get errors using the vectors.

How can I get eclipse to stop giving me errors for this?

EDIT:

example error: Symbol 'vector' could not be resolved

EDIT 2:

I tried to add

using namespace std;

and then using vector blah and that causes a different error:

Invalid template arguments


I've added ${NDKROOT}/sources/cxx-stl/gnu-libstdc++/include

In my project config under C++ General -> Paths and Symbols -> include

Yes, that's it. I've tried to add the same with the same result. However, if you add stl_port headers

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

It will do the trick. Of course it is not necessary to change

APP_STL := stlport_static

as it works only in eclipse indexes. It will be usefull until you are going to use something that exists in gnu-libstdc++ and doesn't exist stl-port.


Blockquote

I am suing eclipse indigo rc2.

I added following line in Android.mk

LOCAL_C_INCLUDES += ${NDKROOT}/sources/cxx-stl/stlport/stlport

and Added following line in Application.mk

APP_STL := stlport_static

then automatically my ndk stlport path added in

Properties -> C++ General -> Paths and Symbols -> include

good luck! ^^


At first, we met the same problem with map and tried to add "Paths and Symbols" as suggested, however it still wouldn't work.

Later on, instead of

#include <map>

we used

#include <stl/_map.h>

The error went away and then we switched back to include <map>. Eclipse no longer complained that "Symbol could not be resolved".

It seems eclipse has a cache and somehow it can get messed up unless you specifically tell it the right place to find the symbols.


I do not know at what stage it worked, but:

  1. Add to Application.mk APP_STL := gnustl_static

  2. Add include to Project properties->C/C++ General -> Paths and Symbols
    'NDK root path'/'your directory to android platform'/arch-arm/usr/include 'NDK root path'/sources/cxx-stl/gnu-libstdc++/4.9/include 'NDK root path'/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include/bits

  3. Turn off all warnings errors in Project properties->C++ General->Code Analisis.

  4. Project properties->C++ Build-> Builder Settings -> Uncheck use default build command. Build command set empty.
  5. Next configure NDK Builder: Project properties-> Builders-> New-> Program and fill Name (your name build conf), Location (path to NDK root directory), Working directory (path to project dir). -> Refresh and check specific resources (your libs folder in project). -> Build Options check Specify working set of relevant resources and change 'jni' folder with your source.

worked in Ubuntu 15.04. Eclipse 3.8.1. Android NDK r10e.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜