12

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 ?

Noha Kareem
  • 1,748
  • 1
  • 22
  • 32
user1002546
  • 143
  • 1
  • 1
  • 5

2 Answers2

24

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
Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335
  • 4
    I was missing this one `/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/include` I added it in Properties => C/C++ General => Code Analasys => Path & symbols and it fixed my errors. – user1002546 Feb 22 '12 at 06:48
  • what if developing for all architectures arm x86 and misp ? – Safareli Nov 04 '13 at 14:06
  • 1
    @Safareli: you should probably select only one of them and add it. I guess the headers are largely the same for different architectures, so it shouldn't be a huge problem. – Violet Giraffe Nov 04 '13 at 14:47
  • 1
    @fnc12: welcome. Find peace in the thought that it was _only_ two hours :) – Violet Giraffe Nov 02 '15 at 19:24
6

Some people have been able to fix this problem by adding __GXX_EXPERIMENTAL_CXX0X__ to Eclipse as mentioned in "smart pointers not working with Android NDK r8". But this doesn't work in some versions of Eclipse such as my one (Eclipse Juno v4.2).

So as a work-around hack, I went to Eclipse Preferences -> C/C++ -> Code Analysis, then I changed the severity of some problems from Error to Warning, since I am using NDK to compile my code anyway so these only effect the Indexer. I changed "Symbol is not resolved" and it fixed my errors, but you might also want to change a few others. At first it didn't fix the errors for me until I closed & re-opened the C++ file. Right-clicking on your project and selecting "Index -> Rebuild" might also help refresh it.

Now Eclipse highlights those lines as warnings and allows me to continue building & running & debugging my NDK app.

Community
  • 1
  • 1
Shervin Emami
  • 2,695
  • 25
  • 17