Unresolved inclusion of Qt in Eclipse - eclipse

Eclipse fails to locate Qt includes. Likewise, it fails to provide auto-complete functionality for Qt classes.
I did Project -> Properties -> Paths and Symbols -> Includes -> Add to the include directories of Qt in /usr/include/qt4/. This caused Eclipse to recognize certain certain classes such as QString; however, there is no auto-complete.
I have scoured the web to no avail. How do I make Eclipse index Qt into my project?
Edit: 12/20/12
I have solved my own problem. It appears order of the includes matter. I put
'usr/include/qt4'
'usr/include/qt4/Qt'
'usr/include/qt4/QtCore'
'usr/include/qt4/QtGui'
into Project Properties -> C++ General -> Paths & Symbols. I rebuilt and the auto-complete worked.

You need to add several include directories, those listed by e.g. the command
pkg-config --cflags QtGui QtXml QtSvg QtDBus
(and others Qt packages).

Related

Gtkmm in Eclipse makefile project: "could not be resolved"

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!

Eclipse CDT indexer does not know C++11 containers

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.

Include directory specification not working on Eclipse Juno

I'm using the latest 32bit Eclipse Juno. I've seen many posts about folder inclusion, but none worked for me.
The problem:
#include<iostream>
#include<osgDB/ReadFile>
#include<osgViewer/Viewer>
The compiler (GCC) reports "unresolved inclusion <iostream>" and corresponding unresolved inclusion errors for ReadFile and Viewer.
What I tried, to solve it:
In Project properties > C/C++ General > Paths and symbols > Includes. I added /usr/include/c++/4.4.4/ for all configurations and all languages. This automatically caused the values in C/C++ Build > Settings > GCC C compiler and GCC C++ compiler's includes > include paths to contain the same values.
The unresolved inclusion error persisted.
Then I tried adding iostream to the include files section below the include paths section. Still no use. Even tried closing and re-opening eclipse after the changes. Still no use.
The only other option was to specify the absolute path which worked:
#include "/home/nav/osg/osg/include/osgDB/ReadFile"
#include "/home/nav/osg/osg/include/osgViewer/Viewer"
#include "/usr/include/c++/4.4.4/iostream"
But isn't the right way to do it. Could anyone help with specifying the include paths the correct way?
I had similar problem and it was caused by the indexer not using the correct build configuration. By default, the indexer was set to use global settings, rather than project specific ones (I'm using Nsight, the version of Eclipse by Nvidia).
Go to
Project properties -> General -> Indexer
Tick
Enable project specific settings
Select
Use active build configuration
This might be irrelevant for you. I'm compiling the same project on multiple machines/OS's and hence have different include paths for each build configuration.

eclipse for android c source code - how to resolve compiler head file?

I am now using eclipse to develop driver and daemon on android platform in C code with a pandaboard, and I want to use eclipse plus CDT as an edit and browse tool.
I have imported android-source code into eclipse as a makefile project, and processing with indexer.
My problem is, since there are lots of head files for different archetecture(x86, arm, etc) like etc, etc. Eclipse reports an error like "unresolved inclusion xxx" because there are too much candidates of those files. Can eclipse analysis makefile and select the correct path like compiler if I specify a variable or identifier to notify eclipse just like a makefile option?
Can anyone help me, please?
Thanks,
-Yunfei
For your driver work checkout:
http://wiki.eclipse.org/HowTo_use_the_CDT_to_navigate_Linux_kernel_source
In general when working with a Makefile project you need to give Eclipse a hand so it knows where to find the includes and which preprocessor symbols are defined.
Right click on your project. Select properties -> C/C++ General -> Path and symbols.
Add the most important include paths and the indexer results will become much better.

refresh eclipse cdt system includes

I'm using ecipse cdt developing c++ program. A problem is I moved all my workspace and eclipse package from turbolinux to centos linux. Then it cause a problem, that is system includes are different, but eclipse didn't refresh the include paths. And all the std container classes can not be solved.
Anyone know how to fix this problem?
I was recently bitten by this one myself (actually came to this site in search of an answer ;-) so I'll share what I found:
(these steps reflect Eclipse Indigo SR1)
First, double-check that Eclipse still reflects the old include paths:
project -> properties -> C/C++ General -> Paths and Symbols -> GNU C++
Next, clear the old paths:
project -> properties -> C/C++ Build -> Discovery Options -> GCC C++ Compiler
click the button for "Clear discovered entries now"
Rebuild your project, such that Eclipse picks up on the new include paths
Confirm that the new include paths are set:
project -> properties -> C/C++ General -> Paths and Symbols -> GNU C++
Checked for Eclipse Luna 4.4.0 with Cdt 8.4.0.201406111759.
You may have a look to your workspace/.metadata/.plugins/org.eclipse.cdt.core/ and check for a file named like YourProjectName.language.settings.xml.
Delete this file (better should backup before), then reopen your project (or restart Eclipse) and Cdt should trigger the the GCC Builtin Discovery.
Note that this way may only applyable if your settings are set to project specific Builtin Discovery (not for »Use global provider shared between projects«). → see Project Properties → C/C++ General → Preprocessor Include Paths, Macros etc. → Providers → CDT GCC Built-in Compiler Settings.
For older Eclipse versions (IMHO about until Indigo), the scanner cache files were placed in workspace/.metadata/.plugins/org.eclipse.cdt.make.core/ and named like YourProjectName.sc.
In the newest Eclipse CDT Mars.1 Release (4.5.1) you'll have to delete the ${WORKSPACE}/.metadata/.plugins/org.eclipse.cdt.core/${PROJECTNAME}.randomnumbers.pdom file, and after opening the project, Eclipse should automatically start to reindex the includes.