Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
260 views
in Technique[技术] by (71.8m points)

c++ - Eclipse indexer errors when using STL with Android NDK

I'm using the Android NDK r7 with eclipse Indigo on Ubuntu. I set up my java project to use the C++ nature. I'm using STL on C++ side so I added

APP_STL := gnustl_static

in the Application.mk file.

ndk-build succeed compiling my code and creating a shared object.

However eclipse indexer complains about missing STL symbols. For example

"Method 'push_back' could not be resolved" "Symbol 'vector' could not be resolved"

This happens only when C++ files are open in the editor. Ultimately eclipse won't create my apk. I added path to the gnu STL headers shiped with the ndk (Properties => C/C++ General => Code Analasys => Path & symbols) :

android-ndk-r7/sources/cxx-stl/gnu-libstdc++/include
android-ndk-r7/sources/cxx-stl/gnu-libstdc++/include/bits

Current workaround is to close opened C++ files to make eclipse happy.

Interestingly eclipse indexer's working fine with headers found in

android-ndk-r7/platforms/android-14/arch-arm/usr/include

Is there something I forgot to set up in eclipse ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You have to add path to STL to project settings so that Eclipse indexes it as well. Project->Properties->C/C++ General->Includes. Here's what I have added:

<path_to_NDK>/sources/cxx-stl/gnu-libstdc++/include
<path_to_NDK>/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/include
<path_to_NDK>/platforms/android-9/arch-arm/usr/include

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...