Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Qt 5.0.2 Error LNK1104: cannot open file 'gdi32.lib'
Hello, I have been watching videos on how to create a program using Qt and I want to try it myself and also, I'm trying to learn how to use Qt because I am interested in making a couple of simple games. I have a pretty basic background knowledge regarding C++. I downloaded the Qt 5.0.2(The Windows 8 64 bit since that's what my laptop runs in) and it all works fine. I tried to make a simple program and when I try to build it, I get this error message:
LINK : fatal error LNK1104: cannot open file 'gdi32.lib'
I checked in my C: drive to see if I have a gdi32.lib file and I have it under the library folder which is in the Microsoft SDK folder. I don't know what the problem is. Does it matter if the the .Lib file under the Microsoft SDK is called "Gdi32.Lib," not being exactly named like the one that Qt Creator cannot open? Anything I can do to fix this error?
I would greatly appreciate any help. Thank you for your time.
Hi and welcome to devnet,
Do you have a line like
@LIBS += -lC:/path_to_sdk/path_to_folder_containing_Gdi32.lib@
in your pro file ?
EDIT:add missing -l
No I didn't have that and I included it. The example project didn't give me the LNK1104 error but ended up getting this error:
16:41:58: The process "C:\Qt\Qt5.0.2\Tools\QtCreator\bin\jom.exe" exited with code 2.
Error while building/deploying project analogclock (kit: Desktop Qt 5.0.2 MSVC2012 64bit)
When executing step 'Make'
and after I tried to recompile to make sure that the LNK1104 error does not appear, it still says the LNK1104 error message. I tried to change the slash direction to see if it made any difference and no luck. I'm sure that I have the gdi32.lib file in there.
I don't know what would be the difference between building with the debug and building with the release but I get those errors when I build with the debug. When I try building with the release, it gives me this error:
LNK1181: cannot open input file 'C:\Program.lib'
I don't know much about Qt and I tried looking for information online but I'm still stuck. /:
It's because of the "Program Files" space try the same path with
@LIBS += -l$$quote("C:/Program Files/etc...")@
If that still doesn't work, get the 8.3 path for Program Files
Tried that too and no difference. What's the 8.3 path? What do you mean by that?
The short version name like in the old dos days
MathiasWestin last edited by
I've got the same problem, maybe a stupid question but why is it trying to link gdi32.lib when building a x64 project?
I opened the .pro file from the Qt-examples in Visual Studio 2012 using the add-in
QT5|Open Qt project file (.pro)...
At first it complain on manifest:embedded but that can be solved by setting VS not to embed the mainfest: https://bugreports.qt-project.org/browse/QTBUG-30822
But I only get so far because I get the next error:
LINK : fatal error LNK1104: cannot open file ‘gdi32.lib’
If I create a project from scratch instead of importing there is no problem building and running. Also Opening the .pro file in Qt Creator is working fine.