简体   繁体   中英

Eclipse not updating “built-in” include paths for Android NDK Project after switching to GCC 4.8

I have an Android/Eclipse project that uses the NDK and I've recently enabled c++11 support by adding the following to my Application.mk file:

NDK_TOOLCHAIN_VERSION := 4.8 #same result here with clang
APP_CPPFLAGS += -std=c++11

This basically works fine, c++11 features are available and compile as expected. This goes for ndk-build and Eclipse builds (which just invoke nkd-build), but the eclipse code parser becomes confused now. When I open a file that uses types added to the STL in c++11 (like for example std::unique_ptr ), I get red squiggles and an error entry in the Problems tab saying Symbol 'unique_ptr' could not be resolved . This wouldn't be so bad, but if errors are present in that list Eclipse refuses to launch (or debug) the application. Right-clicking on the #include <memory> line and selecting Open Declaration also opens the wrong (4.6) file.

When checking the project properties under C/C++ General --> Paths and Symbols --> Includes it still lists the old (4.6) includes when Show Built-in values is ticked: Screenshot

Are those just cached from somewhere and I can get it to re-generate those entries? I've obviously tried to Clean and Rebuild the project, with no effect. I'd rather not add them manually if that can be avoided, upgrading the NDK to new versions already requires quite a few changes until it compiles again. Where are these entries generated from and how do I trigger an update?

I wish I could say I have a definitive answer for you, as I've been battling this problem for quite a while myself, but I do have a decent workaround. For starters, the "built-in" entries under "CDT Managed Build Setting Entries", are generated based on the contents of your Application.mk file which is located in the jni directory. There is no other way of changing them, and these are what populate the "Includes" section in the C++ perspective's Project Explorer. But I see that must have read the documentation.html in the NDK installation to see what to put in that file already. The issue then becomes that as soon as you change something or breathe too hard, your includes suddenly and irreversably become unresolved. The workaround for this is to recall the exact path of each include entry, right-click on the project, go to New->Folder , then in the dialog click Advanced , and select Link to Alternate Location (Linked Folder) . Then navigate to the path (or extend a variable if you are fancy) of the include folder, rename it something descriptive (you can't have 4 linked folders named "include"), and voilà! You suddenly have a usable workspace again. I guess the "Includes" section functionality is a bit flimsy still, at least for ADT, and doing this puts the includes on the same footing as other files that are actually in your project. I'd be thrilled if the officially sanctioned mechanism started to work reliably, and I eagerly await news of such. HTH!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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