Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED] Cannot resolve size_t in Qt projects in Eclipse IDE
I've been having a problem with Qt on Eclipse for a while now and I'm out of ideas of what is causing it It's been going on for a number of months and played havoc with one of my university assignments to the point where I had to switch IDE's.
What happens is when I create a Qt Console or Gui project in Eclipse, set the Qt version etc. which all works fine. The problem is when I try to use size_t in any code, Eclipse throws an error telling me 'size_t cannot be resolved'.
I've tried including headers that define size_t such as <cstddef>, <stddef.h> etc. but this doesn't resolve the problem. If I create a normal C or C++ project it doesn't complain, it only complains in a Qt project.
I've used Qt Creator and QDevelop and neither of these complained about size_t. I don't mind using either. I'm just more comfortable in Eclipse as I develop in a few other languages and like to keep my programming in one IDE unless I absolutely have to use something else. It also works with no issue from the command line. I also find Eclipse easier to use than the other two IDES.
I've installed the plugin as instructed on "this":http://qt.nokia.com/products/eclipse-integration/installation-instructions-for-linux-systems page and have installed Eclipse via the package manager on my system. And I'm really not sure what else I can do to try and fix it.
The only workaround I've used is to redefine size_t as an unsigned long but that's not fixing the problem and it's probably going to break something sooner or later.
Any help would be appreciated, I've listed some specifications and software versions below and I can provide screenshots if needed. Any other questions I'll try to answer as best I can.
- Fedora 15 (32 & 64 bit)
- Fedora 16 (32 bit)
- Fedora 17 (32 bit)
- Ubuntu 12.04 (32 bit)
Qt Versions: 4.7 and 4.8
Eclipse Qt Plugin version: 4.6.1
Other things I've tried:
- Included all headers that define size_t (cstdlib, cstddef, stdlib.h, stddef.h, etc.)
- Checked the Qt project has the same includes as a normal C++ project. (Includes are the same, size_t still unresolved)
- Used ssize_t in place of size_t. (This works, but defeats the point)
I've even gone to the extreme to find which files size_t was defined in. I only found one which was /usr/lib/gcc/i686-redhat-linux/4.7.0/include/stddef.h
Edit: I've finally managed to solve this with help from a lecturer from university. I'm not sure why this works but basically I had install the kernel-devel package on my Fedora machine and then make sure I had /usr/lib/gcc/i686-redhat-linux/4.7.0/include/ in my include path. I'm told it's something to do with a bug with Eclipse itself rather than the plugin.
giesbert last edited by
if the toolchail tells you: cannot be resolved, this typically means it's the linker, not the compiler, right? Or is it during the compilation step?
Which compiler toolchain do you use?
Are you sure, you link standard C/C++ libs?
I can't remember off the top of my head. All I know is when I go to build the solution it gives me the error regarding size_t and I think one or two errors along the lines of 'No rule to make target'.
I'll have a look when I get home. in about 6-7 hours.
Edit: Ok, this is what I've just done.
I've created a new Qt console project. It didn't prompt me to choose a toolchain and three problems have appeared in the tab at the bottom
of the IDE.
'make *** No rule to make target
all'. 'make *** No rule to make targetclean'.
'Type 'QCoreApplication` could not resolved.' (This went away after saving the file.)
I typed in size_t i; but I still get the error 'Type 'size_t` could not resolved.'
I got the same errors in a Qt GUI project.
This is a picture of what I have after I did the above mentioned.
!https://dl.dropbox.com/u/4200898/eclipse.png(The end result.)!
If the picture is too small, this is the code:
int main(int argc, char *argv)
QApplication a(argc, argv);
There seems to be no options for configuring toolchains in Juno and Google isn't pulling up any results at all.
Anyone else have an idea where I'm going wrong?