Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Symbols from included headers are not to be found
Symbols from included headers are not to be found [message #793570] Wed, 08 February 2012 09:51 Go to next message
Marcell Kehmstedt is currently offline Marcell KehmstedtFriend
Messages: 5
Registered: February 2012
Junior Member
Hello,

I have got some very annoying problems with Eclipse, which I'd like to ask you for some help. Smile

I created a makefile project and imported my sources, headers and all the other stuff of my existing project into it.
Then I created a builder configuration for a qmake makefile generation process and as toolchain I selected "MacOSX GCC".
Under "Paths and Symbols" I added my QT headers which are also displayed in the project explorer.

Here comes the problem:
I am able to create a makefile using my qmake makefile generation process and I am also able to compile the project using the 'default' build in eclipse (and also on console).
Within my header files, which include the QT headers, everything is fine so far (except little qt specific details like the macro Q_OBJECT is not known as well as "public slots:" and so on).
But when I open one of my source files, which include those headers, nearly everything is marked red!
Eclipse tells me that all of those QT symbols "could not be resolved".

Why is that? And how I can make Eclipse resolve those symbols from the included headers?

I'm really looking forward to your answers.
Thanks so far.

Kind regards,
Marcell
Re: Symbols from included headers are not to be found [message #793684 is a reply to message #793570] Wed, 08 February 2012 12:40 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
Marcell Kehmstedt wrote on Wed, 08 February 2012 10:51

Under "Paths and Symbols" I added my QT headers which are also displayed in the project explorer.

Did you add all possible include paths? Subfolders are not automatically included! Did you add the include paths to C and C++?

Quote:

Within my header files, which include the QT headers, everything is fine so far (except little qt specific details like the macro Q_OBJECT is not known as well as "public slots:" and so on).

That is already an error. These macros should be resolved. Are the Qt includes marked as unresolved?

Quote:
And how I can make Eclipse resolve those symbols from the included headers?

I would suggest to create a linked folder in your Eclipse project that contains the Qt headers.


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Symbols from included headers are not to be found [message #793964 is a reply to message #793684] Wed, 08 February 2012 19:38 Go to previous messageGo to next message
Marcell Kehmstedt is currently offline Marcell KehmstedtFriend
Messages: 5
Registered: February 2012
Junior Member
Axel Mueller wrote on Wed, 08 February 2012 07:40
Marcell Kehmstedt wrote on Wed, 08 February 2012 10:51

Under "Paths and Symbols" I added my QT headers which are also displayed in the project explorer.

Did you add all possible include paths? Subfolders are not automatically included! Did you add the include paths to C and C++?

Yes, all paths with header and source files are added to the project and are shown within the project explorer. And all those include paths are added to the include directories (under Paths and Symbols) for C and C++ as well.

Axel Mueller wrote on Wed, 08 February 2012 07:40

Quote:

Within my header files, which include the QT headers, everything is fine so far (except little qt specific details like the macro Q_OBJECT is not known as well as "public slots:" and so on).

That is already an error. These macros should be resolved. Are the Qt includes marked as unresolved?

No. The include directives like
#include <QtGui>

are not marked yellow or red and I am possible to open those files from within Eclipse when right clicking on that directive and selecting "Open Declaration".

Axel Mueller wrote on Wed, 08 February 2012 07:40

Quote:
And how I can make Eclipse resolve those symbols from the included headers?

I would suggest to create a linked folder in your Eclipse project that contains the Qt headers.

Hmm, that might be a work around, I would not like to do - whether it might work or not.
The reason is, that I would like set up an Eclipse project that I can transfer to another machine for testing and debugging reasons, because the machine I'm developing on is not the target machine.
I mean, there must be a legal way of adding includes in a standard way.

Maybe I should give you an example, so you can understand my problem.
Here is an excerpt from the header file (MainWindow.h) of my MainWindow:
#include <QtGui>

class MainWindow : public QMainWindow //<- no warnings or errors from Eclipse!
{
	Q_OBJECT //<- Syntax error
public:
	MainWindow(QWidget * parent = 0, Qt::WindowFlags flags = 0); //<- Type 'Qt::WindowFlags' could not be resolved
	virtual ~MainWindow();

public slots: //<- Syntax error
};

And here is an excerpt from the corresponding source file:
#include "MainWindow.h"

MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags flags) : QMainWindow(parent, flags) //<- Member declaration not found
{
    setWindowTitle(); //<- Could not be resolved
    setCentralWidget(); //<- Could not be resolved
}

Both files are placed within the same folder and this folder is part of the include directories within the project properties.

I hope this helps a bit. And thank you for your answer so far! Smile
Re: Symbols from included headers are not to be found [message #794416 is a reply to message #793964] Thu, 09 February 2012 09:01 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
OK, I see the problem.
You use
#include <QtGui>

The file QtGui includes all GUI headers. Unfortunately, this file has no ending. So Eclipse does not index it (and all the included headers). So when you open QtGui (select with the mouse and press F3) you will see that you cannot navigate further.
So you have two possibilities:
1)
In Project Properties->C/C++ General->File Types add QtGui as C++ header
=> Eclipse will recognize the file QtGUI as a C++ header and add it to the index.

You have to do this for every header of this type (QtCore etc..)

2)
Create a linked folder in your Eclipse project that contains the Qt headers; you can use variables of the kind PATH_TO_QT to make it portable


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Symbols from included headers are not to be found [message #794511 is a reply to message #794416] Thu, 09 February 2012 11:35 Go to previous messageGo to next message
Marcell Kehmstedt is currently offline Marcell KehmstedtFriend
Messages: 5
Registered: February 2012
Junior Member
So, I tried your first possibility and added QtGui, QtCore and so on as C++ Header files to the file types listing.
But in fact that doesn't make any difference. Closing and reopening Eclipse does not have any effect as well as rebuilding the index.
What could that mean?
Re: Symbols from included headers are not to be found [message #794535 is a reply to message #794511] Thu, 09 February 2012 12:10 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
That's weird. When you add
Quote:
#include <QtCore/QObject>

to your MainWindow.h is the macro QOBJECT resolved?

Do you use different build configurations?


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Symbols from included headers are not to be found [message #794566 is a reply to message #794535] Thu, 09 February 2012 12:58 Go to previous messageGo to next message
Marcell Kehmstedt is currently offline Marcell KehmstedtFriend
Messages: 5
Registered: February 2012
Junior Member
No it's not. But the directory structure for my qt headers is a bit different. So all headers like qobject.h are accessible without subdirectories.
But with that structure
#include <qobject.h>

should do it. But that's not the case either.

I'm not quite sure to distinguish the different meanings of build configuration witihn Eclipse.
But under Project->Properties->C/C++ Build->Configuration there is [Default] selected.
My only change was made under Project->Properties->Builders, where I added a launch configuration for the qmake Makefile generation.
Re: Symbols from included headers are not to be found [message #794582 is a reply to message #794566] Thu, 09 February 2012 13:15 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
OK, you are hit by a bug that only occurs on Mac.
Here is an explanation and a workaround.
http://www.eclipse.org/forums/index.php?t=msg&S=24f575d9221d764939fc879f51eed076&th=206504&goto=661592#msg_661592


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Symbols from included headers are not to be found [message #794586 is a reply to message #794582] Thu, 09 February 2012 13:22 Go to previous message
Marcell Kehmstedt is currently offline Marcell KehmstedtFriend
Messages: 5
Registered: February 2012
Junior Member
Ok. Seems I have some big extra work to do.
But I will try it. Thanks so far! Smile

But here comes another funny issue:
The same problem I described above for my Mac appears in the same form on the target machine running Scientific Linux.
The only thing I haven't tried on that machine is to modify the file types listing in Eclipse as you discribed it above.
I am going to do this in a moment...

[Updated on: Thu, 09 February 2012 13:22]

Report message to a moderator

Previous Topic:Simple Error
Next Topic:-run-exec in Eclipse --> CodeSourcery/arm-none-eabi-gdb --> gdb --> Atollic/gdbserver ?
Goto Forum:
  


Current Time: Thu Apr 25 22:14:26 GMT 2024

Powered by FUDForum. Page generated in 0.03831 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top