I configured a C++11 project in Eclipse CDT to use gcc-4.7. It is not the default compiler on my system, which does not support C++11. In order for compilation to work, I need to pass the flag -std=c++11 and also include the following header path: /usr/local/Cellar/gcc/4.7.2/gcc/include/c++/4.7.2
Whenever I use C++11 container types like std::unordered_set or std::unordered_map, the CDT indexer complains: Symbol unordered_set could not be resolved. How can I tell the indexer to resolve these symbols correctly?
This is how I have configured my indexer:
As far as I understand the settings, the indexer is supposed to use the compiler settings from the currently active build configuration. Compilation works fine, so why doesn't indexing, too?
Setting up **__GXX_EXPERIMENTAL_CXX0X__** does not help in my case (Jul 2014, Eclipse Kepler 20130919, Ubuntu 12.04).
To fix C++11 syntax highlighting go to:
Project Properties --> C/C++ General --> Paths and Symbols --> Symbols --> GNU C++
and overwrite the symbol (i.e. add new symbol):
__cplusplus
with value
201103L
UPDATED: If you use newer version of Eclispe (as of 2016) and still experience the same problem, try value (as pointed by jose.diego):
201402L
Make sure that indexer is enabled in Project settings (C/C++ general --> Indexer)
Then reindex (Project --> C/C++ Index --> Rebuild)
if the problem still persist reindex once again. It should work now.
I solved this problem recently after some lucky googling.
Click on your project and right-click->Properties
Select "C/C++ General -> Processor Include Paths, Macros etc..."
Select the "Providers" tab
Deselect everything except "CDT User Setting Entries" and "CDT GCC Built-in Compiler Settings"
Click on "CDT GCC Built-in Compiler Settings"
Deselect "Use global provider shared between projects"
Edit the box at the bottom labeled "Command to get compiler specs"
Insert into the command -std=c++11 so it looks something like this:
${COMMAND} -std=c++11 -E -P -v -dD "${INPUTS}"
Click Apply and Okay.
That worked for me. You probably need to re-index the project.
As described in this forum post:
http://www.eclipse.org/forums/index.php/mv/msg/282618/
right-click the project and go to "Properties" C/C++ General -> Paths
and Symbols -> Symbols -> GNU C++.
Click "Add..." and paste __GXX_EXPERIMENTAL_CXX0X__ into "Name" and
leave "Value" blank. Hit Apply, do whatever it asks you to do, then
hit OK.
Or go to:
C/C++ Build->Discovery Options->GCC C++ Compiler
add your flags to the Compiler invocation arguments. like -std=c++11 -m32
Clear discovered entrys now: click on Clear
rebuild the project
After that ALL symbols will be updated with correct values and the indexer should work as intended
The workaround for me, with a project that uses an external builder, was to define the symbol:
__cplusplus
with the value:
201403
in the project's: Paths and Symbols -> Symbols/GNU C++.
This worked in eclipse Kepler CDT Version: 8.3.0.201402142303.
See this guide:
C/C++ Build->Settings->GCC C++ Compiler->Dialect
Choose "ISO C++11 (-std=c++0x)" in "language standard"
Apply and OK
Rebuild the project and it works:)
The follows works in Eclipse C/C++ Oxygen.2 with gcc-5.5.0
Eclipse Properties->C/C++ Build->Settings->GCC C++ Compiler->Dialect->Other dialect flags: -std=c++17
Don't pick up anything in the Language standard dropdown list.
The following configuration helps me to fix the issue indicated in the original question.
Environment:
Eclipse(Oxygen.3a Release (4.7.3a)), Cygwin64.
In case you have a different version of Cygwin, you can find similar directories as follows.
Step 1: Make sure you have the following two directories:
C:\cygwin64\lib\gcc\x86_64-pc-cygwin\7.4.0\include
C:\cygwin64\lib\gcc\x86_64-pc-cygwin\7.4.0\include\c++
If you don't see the above two directories, please launch your Cygwin setup program and install gcc-core, gcc-g++ and libgcc1.
Step 2: Copy the directory C:\cygwin64\lib\gcc\x86_64-pc-cygwin\7.4.0\include to C:\cygwin64\usr if you don't see above two include directories.
Step 3: Go to Project Property->C/C++ General->Paths and Symbols
Make sure you can see the following two paths are listed
C:\cygwin64\usr\include
C:\cygwin64\usr\include\c++
Step 4: Property->C/C++ Build/Settings/ Choose Cygwin PE Parser
Step 5: Property->C/C++ Build/Tool Chain Editor Choose Cygwin GCC
Step 6: Property->C/C++ General/Indexer Choose Enable indexer
Step 7: Project->C/C++ Index->Rebuild
Now your eclipse should be able to see the C++11 types.
Related
I am trying to migrate a custom C++ project which uses Gtkmm3.0 to Eclipse (Oxygen) on Ubuntu 16.04. The project has its own Makefile and builds fine from the terminal within Eclipse. What I have not been able to do so far is tell the indexer about Gtkmm, and I get lots of these (which is very annoying):
When I hover over the little red bugs, it says:
Type 'Cairo::RefPtr<Cairo::Context>' could not be resolved.
I have done a lot of Googling on this and found nothing so far because all answers seem to assume the project's build tools are managed by Eclipse (See this or this, for example). In my case I have a makefile project instead of an executable project and hence some options are not available to me. For example, the first links speaks about configuring the builder:
We have to add all this directories. On Eclipse select the Project->Properties menu option. Select C/C++ Build->Settings property page and GNU C++ Compiler->Directories from the Tool Settings tab. Now we have to add all directories. In my case (Makefile project) only two tabs are available there: Binary Parsers and Error Parsers.
How can I tell the Eclipse indexer I am using Gtkmm3.0?
Found the solution that works for me:
Open a terminal and enter:
pkg-config --cflags gtkmm-3.0
You will see a list of includes directories (starting with -I). These are the directories you want to add in Eclipse so that it can locate the Gtkmm symbols in the editor.
In Eclipse, go to:
Project -> Properties -> C++ General -> Paths and Symbols
In the Includes tab, select GNU C++. You need to add here add the include directories found in step 1. There is no automated way to do this, yo must enter them one by one.
One trick that can save you some time is to edit manually the Eclipse project setting XML file and add the include directories directly in the XML file. By the end, you should have something that looks like this:
That did it for me, hope this helps!
I have eclipse Luna.I want to use auto variable in my project and for that i need to enable c++11 in eclipse.I have followed this answer Eclipse CDT C++11/C++0x support
But in my project's property, there are no option like c/c++ Build. There are only one option named c/c++ General.
So using c/c++ general how can i enable c++11 in my eclipse.Please anybody know the solution then mention steps.thanks.
For Eclipse Luna, go to Project > Properties > C/C++ Build > Settings > Tools Settings > Cross G++ Compiler (or whichever compiler setting you're using) and choose "ISO C++1y (-std=c++1y)" or "ISO C++11 (-std=c++0x)". Or instead, in "Other dialect flags", you can put std=c++11, or std=c++14, but if you do it this way you'll probably have to take an additional step not covered here so the Eclipse editor will produce error flagging for the correct C++ version in the editor.
I am working with c++ and it got type __uint128_t in the code. The code compiles fine on g++ (GCC) 4.8.3, but Eclipse/CDT always show error on "__uint128_t". The actual error message is "Type '__uint128_t' could not be resolved".
I tried several things already, including re-index, adding -std=c++11 to compiler's setting. Does anybody know how to make the error message disappear?
I am running Eclipse Luna Release (4.4.0) and CDT 8.4.0.
Eclipse will be able to correctly "parse" this type only if it's defined in some header of your toolchain. If it is a builtin type in compiler (just like "int", "char" and so on) - and I guess it is - then Eclipse would need to have special code to handle that type. So unless someone implements handling of this token in Eclipse, your only option is to disable this particular code analysis check for the files that use this type...
unchecking "Use global provider shared between projects" and adding -std=c++11 to the command line for the compiler specified in the "CDT GCC Built-in Compiler Settings", which can be found by opening project properties and going to "C/C++ General", "Preprocessor Include Paths", "Providers" tab.
then rebuilding the index: right-click the project, "Index", "Rebuild".
for detail please refer to the answer by davmac in post: Type 'uint32_t' could not be resolved
I had similar difficulties with Eclipse Oxygen.3 (with CDT 9.4 on Debian 7.10 64-bit, and GCC 4.7.2). I tried everything mentioned on StackOverflow as of March 30, 2018 to no avail.
Several headers in my project were being included by multiple source files. These headers were protected by #ifdef guards, but Eclipse CDT's CODAN code analysis system didn't seem to permit these guarded headers to apply to more than one .cpp source file. So numerous types and functions which returned those types were not recognized.
But after setting Window > Preferences > C/C++ > Indexer > Index all header variants, and then Rebuilding the index for the project, subsequent code analysis runs succeeded.
See a related answer from me if trying to utilize workspace-level settings.
This is driving me NUTS. I recently tweaked around with my C Project's:
C/C++ General ->Paths and Symbols->Includes->GNU C->Include Directories.
Now, I get the following Error listed:
Program "-E" not found in PATH
Location: Project Properties, C++ Preprocessor \
Include.../Providers, [CDT Cross GCC Built-in \
Compiler Settings] options
Short of making a new Workspace and starting over, what the heck does this mean, and how do I fix my current project???
Note
Closing Eclipse, Checking out the project from Source-Control Fresh, and restarting still shows the problem!!! How the heck can this be.
-Justin
I had quiet similar problem, in my case changing toolchain from Linux GCC to Cross GCC in project properties (C/C++ Build -> Tool Chain Editor -> Current toolchain) resolved the issue
In the project settings go to "C/C++ Build > Tool Chain Editor". The selected tool chain was empty in my case. Thus I selected the tool chain that I use (which seems to be "Cross GCC" in your case). This will set the ${COMMAND} variable (and ${FLAGS} and ${INPUTS}), which seems to be unset in your case. If you for example close the project and reopen it the error should be gone.
The second option I see is that the command with which Eclipse determines the default definitions and include paths of your compiler/tool chain got screwed up when you "tweaked your project". You should be able to fix this as follows: Open the project settings and go to "C/C++ General > Preprocessor Include Paths, Macros etc.", select the "Providers" tab, select the active "CDT * Built-in Compiler Settings" provider from the list and make sure that the "Command to get compiler specs" starts with '${COMMAND} -E' instead of '-E'. In my case the complete line is '${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"'. If you no longer want to see the output when Eclipse is executing this command you can uncheck "Allocate console in the Console View".
I have had this problem for months and finally found a solution for my Eclipse.
I noticed that this problem appeared in some of my projects but not in all of them, and after checking the .cproject options I realized that somehow Eclipse is using some variables that are either not defined or not expanded properly, in my case ${CXX} and ${CC}.
So my solution is to go to Preferences > Run/Debug > String Substitution and create two string substitution variables:
CC=gcc
CXX=g++
Clean the errors from the console, restart Eclipse and the errors are gone.
Hope that helps.
Are you using GCC Compiler for ARM ?
In that case you should install ARM Eclipse plugins from http://gnuarmeclipse.livius.net/blog/
So there has been an overhaul of the scanner discovery as worked on here:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=290631
http://dev.eclipse.org/mhonarc/lists/cdt-dev/msg24345.html
However, I can't find any information on how to use it. I upgraded from Helios to Juno recently and now I have 8000 "Semantic Errors" and a ton of unresolved includes. However, I can't figure out how to use this new feature. I don't think there's any documentation yet, either.
I think the intent is it will scan your project and automatically discover macros and include directories in order to aid in symbol resolution and project navigation.
I'll keep working on it and update this question if I ever figure it out.
Figured it out.
Used this as a guide: https://developer.mozilla.org/en/Eclipse_CDT
In the project properties, "C/C++ Build", I replaced the default build command with my build command. I had to remove a -s switch (silent switch) so the output parser could grab all the paths and macros from the compiler commands. Pointed the "build directory" to the directory with my makefile.
Under "C/C++ General" > "Preprocessor Include Paths, Macros etc." > "Providers" I selected CDT User Setting Entries and CDT GCC Build Output Parser. I then had to change the compiler command pattern to match my gcc cross compiler. To do that, I just changed "gcc" to "arm-elf-gcc".
After a full build (do not use multi-core builds for the first indexing), right click your project, click 'index' and 'rebuild'. After this, the output parser populated the indexes correctly and they showed up under "C/C++ General" > "Preprocessor Include Paths, Macros etc." > "Entries"