[Qt-creator] Code completion is unable to find header files

Nikos Chantziaras realnc at gmail.com
Mon Dec 31 11:19:11 CET 2012


I've run into a nasty problem with Qt Creator (I'm using 2.6.1 on Gentoo 
Linux) where it can't find header files I include and thus code 
completion for anything in those headers isn't working.

Case in point:

   #include <SDL.h>

Creator can't find it because the full path to that header is:

   /usr/include/SDL/SDL.h

However, I don't want to use:

   #include <SDL/SDL.h>

instead.  That's not the correct way to do it, as it breaks portability. 
  Some systems don't use "SDL/" but can have that header in "SDL1.2/" or 
"SDL12/" or "SDL-1.2/" or whatever.  The correct way to do this is to 
use pkg-config.  In my project file:

   CONFIG += link_pkgconfig
   PKGCONFIG += sdl

Qt Creator is not able to pick that up.  So as a workaround, which seems 
to work fine with generic projects, I provided a "ProjectName.includes" 
file with this in it:

   /usr/include/SDL

But Creator doesn't seem to care.  This works just fine for non-qmake 
projects.  But with qmake projects, Creator seems to ignore *.includes 
files?

What can I do?

This is of course not limited to SDL. The same problem arises with 
anything that uses pkg-config to provide include paths and you're not 
supposed to hardcode the path prefix into your #include directives.




More information about the Qt-creator mailing list