QT c++ “Windows.h no such a file or dictionary in main.ccp”


My Qt c++ cross platform game work with windows but when it comes to the Linux there is an error “Windows.h no such a file or dictionary in main.ccp“.


Windows.h is, unsurprisingly, a Windows-only header file. It doesn’t exist on Linux. You’ll need to find a Linux-compatible way of doing whatever you’re trying to do (or seeing as you’re already using QT, a cross-platform way).
no such a file or dictionary are you sure it isn’t no such file or directory?
Since you’re using Qt, why are you including Windows.h to begin with? Is there something from that header that you actually need?
“Windows.h” “cross platform” pick zero or one of the above.



How would you expect windows.h to exist on a nom-Windows OS? On Linux you’re supposed to have qt.h or so (and change those library function calls to Qt ones, instead of WinAPI).

windows.h is available only on Windows XP or newer (and Windows 2000 Professional). You can only choose one option: cross-platform or Windows.

I also doubt your program is right, since main.ccp is not a valid name for a C++ source file.



You only need windows.h on Windows-Platforms. So my best advice for you is to use this:

#ifdef WIN32
#include "windows.h"

This will include windows.h only if you are on Windows.


Then how would the program compile if one of the lines reads CreateWindowEx(blah blah)?
This is a Windows Function. Therefore you cannot use it. For OpenGL, the easiest way to do it is by using GLUT or SDL.
That would require extra job for an already-written code.
Qt does it for you. Please give us your main.cpp




Add a Comment