Really strange problems with QtCreator


Vorporeal

Yes, no, I, this is.
Joined
Sep 13, 2007
Messages
1,614
Age
33
Website
Visit site
I'm having this INCREDIBLY annoying problem with QtCreator. My code compiles fine and works, but the code-completion in the IDE is failing me. It says for all of my #includes that the file could not be found. This is obviously wrong, as the code compiles and runs with no problems. This is really getting on my nerves, and is making coding orders of magnitude slower. Any ideas?
 
Vorporeal said:
I'm having this INCREDIBLY annoying problem with QtCreator. My code compiles fine and works, but the code-completion in the IDE is failing me. It says for all of my #includes that the file could not be found. This is obviously wrong, as the code compiles and runs with no problems. This is really getting on my nerves, and is making coding orders of magnitude slower. Any ideas?
Everything in /usr/include, and in INCLUDEPATH, is accessible, and you have to load the headers with the .h if the header is non-standard (as per the C++ standard).
Note that you can modify your includepath in your project.pro-file by adding the line "INCLUDEPATH+=folder"

For example, when I want to load an OGRE header, I type "#include <OGRE/OgreRoot.h>" since OGRE/OgreRoot.h is in /usr/include and everything seems to work as expected. Project-internal headers work the same way since includepath includes the project dir.

Please tell us about which headers are unloadable and we'll try to diagnose your problem further :p

EDIT: the "Projects" tab in QtCreator is very helpful if you want a GUI to play with your project.
EDIT2: Also see here and here.
 
(First off, I'm using it on Windows, but I can make the Lin->Win conversions fine.)
(Second, I know a good amount about developing, so that might help you some with your responses.)

I'm using it on windows with mingw. I put the SDL includes in C:/MinGW/include/SDL/... - I should therefore be able to just "#include "SDL/SDL.h". And yes, that works. The problem is that QtCreator says "file not found", and therefore code-completion fails. Everything compiles without a hitch though, as the header actually exists right there. It doesn't just do this for user-added libraries - "#include <iostream>" and "#include <stdio.h>" fail in exactly the same way.

EDIT: I'm not using any headers that require me to change the INCLUDEPATH. They're all in the project folder or in the <pathtomingw>/include folder (or subdirectory).
 
Vorporeal said:
(First off, I'm using it on Windows, but I can make the Lin->Win conversions fine.)
(Second, I know a good amount about developing, so that might help you some with your responses.)

I'm using it on windows with mingw. I put the SDL includes in C:/MinGW/include/SDL/... - I should therefore be able to just "#include "SDL/SDL.h". And yes, that works. The problem is that QtCreator says "file not found", and therefore code-completion fails. Everything compiles without a hitch though, as the header actually exists right there. It doesn't just do this for user-added libraries - "#include <iostream>" and "#include <stdio.h>" fail in exactly the same way.

EDIT: I'm not using any headers that require me to change the INCLUDEPATH. They're all in the project folder or in the <pathtomingw>/include folder (or subdirectory).
Please check your default compiled includepath (with the command "$(gcc -print-prog-name=cc1plus) -v").
If your MinGW includepath is in there, it seems that Creator and cpp aren't in sync when it comes to includedirs somehow.
Try going to "Projects->[chose project]->[chose your target]->Build Environment" and choosing "Clear system environment", which ensures that qmake runs with a clean environment (I dunno if your includepath is set globally or not, but better to be on the safe side). You will also need to set all of your envs manually (you can do so in the same window btw), especially PATH, so that qmake can find everything it needs such as make etc.

I'm currently pulling and compiling the creator source, so I'll see exactly which paths are searched. BRB with more info.

EDIT: QtCreator uses the output of "g++ -xc++ -E -v -" to generate it's default include paths. It literally parses that output by searching for the "#include <"-line and including all folders mentioned after that line, until "End of search list.". Basically, it uses all the include dirs that g++ says it has.

So, the problem must lie with your g++/cpp version that has other include paths than it reports. Try using that info.

You can also try to hack on "qt-creator/plugins/project-explorer/toolchain.cpp" line 128 in "git://labs.trolltech.com/qt-creator" if the problem seems to be something else.

If nothing else works, as a last resort, it might be necessary to add the C:/MinGW/include/-folder to includepath even if it's a default path; sometimes strange devsystems just don't work.
 
Well, manually adding C:\MinGW\include to the INCLUDEPATH fixes most of the issues - stdlib.h works, so does SDL.h (standard and user added libraries). The only things failing now are "#include <string>" and "#include <iostream>". Any thoughts there?
 
Vorporeal said:
Well, manually adding C:\MinGW\include to the INCLUDEPATH fixes most of the issues - stdlib.h works, so does SDL.h (standard and user added libraries). The only things failing now are "#include <string>" and "#include <iostream>". Any thoughts there?
Well, since iostream.h in fact is in a user-specified location and not in the standard path, creator sees it as user-created header and not as a built-in one.
Fast solution:
Write "#include <iostream.h>" and let the C++ purists kill you.

Slow but more stable solution:
Move your headers to a folder reported by "g++ -xc++ -E -v -"; then you can use the standard C++ conventions.

Alternatively, try to apply the following patch to QtCreator (I wrote it myself and haven't had the opportunity to see if it works; change it as you see fit):
(You of course have to set your MinGW path on the QT version options page for this to work)
 
*BUMP*

Just wondering whether this solution worked for you or not; I'm showing QtCreator to a friend and would like to know if the problem remains with MinGW so that I don't have to patch his version if not strictly necessary.
 
Back
Top