0

I'm using Eclipse Juno with the ADT (Android Developer Tools) plugin downloaded from https://dl-ssl.google.com/android/eclipse/.

I created an Android application project with Native Support enabled (right click on the project → "Android Tools" → "Add Native Support").

Despite targeting C++11 in my Application.mk and Android.mk files, Eclipse fails to resolve symbols like std::thread or std::unique_ptr, but when I build the project it compiles well: The only problem is C++11 symbols resolution.

How can I make Eclipse resolves C++ 2011 symbols correctly?

HRold
  • 229
  • 1
  • 10
  • 2
    @HRold - you just have to wait the 8 hours and then post your answer. I've removed the "[Solved]" from the title and the answer. The answer is still in the revision history so you can recover it from there to post when you can. – ChrisF Aug 08 '14 at 14:27

1 Answers1

2

If your Eclipse Juno with ADT plugin can compile C++11 code but fails to resolve C++11 symbols, here is the procedure:

  1. Open your .cproject file in a text editor.

  2. Search the following line (where XXXXXXXXX is a random number):

    <tool id="com.android.gcc.compiler.XXXXXXXXX" name="Android GCC Compiler" superClass="com.android.gcc.compiler">
    
  3. Add the following into it:

    <option id="com.android.gcc.compiler.option.preprocessor.def.768340103" superClass="com.android.gcc.compiler.option.preprocessor.def" valueType="definedSymbols">
        <listOptionValue builtIn="true" value="__cplusplus=201103L"/>
        <listOptionValue builtIn="false" value="__cplusplus=201103L"/>
        <listOptionValue builtIn="true" value="__GXX_EXPERIMENTAL_CXX0X__"/>
        <listOptionValue builtIn="false" value="__GXX_EXPERIMENTAL_CXX0X__"/>
    </option>
    

    You should have something like this (where YYYYYYYYYY is also a random number):

    <tool id="com.android.gcc.compiler.XXXXXXXXX" name="Android GCC Compiler" superClass="com.android.gcc.compiler">
        <option id="com.android.gcc.compiler.option.preprocessor.def.768340103" superClass="com.android.gcc.compiler.option.preprocessor.def" valueType="definedSymbols">
            <listOptionValue builtIn="true" value="__cplusplus=201103L"/>
            <listOptionValue builtIn="false" value="__cplusplus=201103L"/>
            <listOptionValue builtIn="true" value="__GXX_EXPERIMENTAL_CXX0X__"/>
            <listOptionValue builtIn="false" value="__GXX_EXPERIMENTAL_CXX0X__"/>
        </option>
        <inputType id="com.android.gcc.inputType.YYYYYYYYYY" superClass="com.android.gcc.inputType"/>
    </tool>
    
  4. Save modifications, restart eclipse and if C++11 symbols are still not resolved rebuild your index (right click on the project → "Index" → "Rebuild").


Because the "Symbols" tab was not visible in the C/C++ options of the project, I was forced to add these lines manually in the .cproject file in order to set the value of __cplusplus to 201103L.

I don't know exactly how .cproject files works so there's probably a better way to do it. I've seen some guys changing the toolset options of the project in order to make the "Symbols" tab visible (here Android NDK build, Method could not be resolved and here Setting up C++11 (std::thread) for NDK with ADT/Eclipse).

Community
  • 1
  • 1
HRold
  • 229
  • 1
  • 10