:-1: error: LNK1104: cannot open file 'kernel32.lib'
-
by the way, my .pro looks like this:
QT += core
QT -= guiCONFIG += c++11
WIN32:LIBS += C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10586.0/um/x64/kernel32.lib
INCLUDEPATH += C:/Users/Del Noble/Documents/Dev/c++/abcTARGET = JME_Test
CONFIG += console
CONFIG -= app_bundleTEMPLATE = app
SOURCES += main.cpp
-
by the way, my .pro looks like this:
QT += core
QT -= guiCONFIG += c++11
WIN32:LIBS += C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10586.0/um/x64/kernel32.lib
INCLUDEPATH += C:/Users/Del Noble/Documents/Dev/c++/abcTARGET = JME_Test
CONFIG += console
CONFIG -= app_bundleTEMPLATE = app
SOURCES += main.cpp
@Papa
Hello,
This snippet should suit you:# This will only work on windows in any case, so specifying a platform seems redundant LIBS += -L"C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10586.0/um/x64/" -lkernel32
Why you'd want to link
kernel32
, however, is beyond my abilities to comprehend.Kind regards.
-
Thanks kshegunov, now my pro looks like this:
QT += core
QT -= guiCONFIG += c++11
WIN32:LIBS += C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10586.0/um/x64/kernel32.lib
LIBS += -LC:/Program Files (x86)/Windows Kits/10/Lib/10.0.10586.0/um/x64/ -lkernel32
INCLUDEPATH += C:/Users/Del Noble/Documents/Dev/c++/jmeTARGET = JME_Test
CONFIG += console
CONFIG -= app_bundleTEMPLATE = app
SOURCES += main.cpp
---- However, I am still getting the same error.
-
Thanks kshegunov, now my pro looks like this:
QT += core
QT -= guiCONFIG += c++11
WIN32:LIBS += C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10586.0/um/x64/kernel32.lib
LIBS += -LC:/Program Files (x86)/Windows Kits/10/Lib/10.0.10586.0/um/x64/ -lkernel32
INCLUDEPATH += C:/Users/Del Noble/Documents/Dev/c++/jmeTARGET = JME_Test
CONFIG += console
CONFIG -= app_bundleTEMPLATE = app
SOURCES += main.cpp
---- However, I am still getting the same error.
@Papa
Hello,
You either useWIN32:LIBS
orLIBS
not both with the same argument(s). Because you're trying to link a very basic system library that is available only on windows, and presumably, you intend to use some platform specific functions, it's a good bet you won't be running your app on other platforms. This is why I said that specifying the OS seemed redundant. Additionally you must quote your path (as done in my example), because it contains spaces.Kind regards.
-
OK, now it looks like this:
QT += core
QT -= guiCONFIG += c++11
WIN32:LIBS += C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10586.0/um/x64/shell32.lib
WIN32:LIBS += C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10586.0/um/x64/ -lkernel32.lib
WIN32:LIBS += -LC:/Program Files (x86)/Windows Kits/10/Lib/10.0.10586.0/um/x64/ -lkernel32
INCLUDEPATH += C:/Users/Del Noble/Documents/Dev/c++/jmeTARGET = JME_Test
CONFIG += console
CONFIG -= app_bundleTEMPLATE = app
SOURCES += main.cpp
--- However, the problem remains
-
OK, now it looks like this:
QT += core
QT -= guiCONFIG += c++11
WIN32:LIBS += C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10586.0/um/x64/shell32.lib
WIN32:LIBS += C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10586.0/um/x64/ -lkernel32.lib
WIN32:LIBS += -LC:/Program Files (x86)/Windows Kits/10/Lib/10.0.10586.0/um/x64/ -lkernel32
INCLUDEPATH += C:/Users/Del Noble/Documents/Dev/c++/jmeTARGET = JME_Test
CONFIG += console
CONFIG -= app_bundleTEMPLATE = app
SOURCES += main.cpp
--- However, the problem remains
@Papa
Hello,
I don't understand why you didn't do as I suggested, perhaps I hadn't explained myself clearly? Your.pro
file should look something like this (note the the quoted paths):# ... Some stuff CONFIG += c++11 win32 { #< This only spares me to write win32:LIBS at every line # You must use quoted paths when they contain spaces LIBS += "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10586.0/um/x64/kernel32.lib" LIBS += "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10586.0/um/x64/shell32.lib" } # Again, use quoted paths INCLUDEPATH += "C:/Users/Del Noble/Documents/Dev/c++/jme" # ... More stuff
Here you can find more information on the
LIBS
qmake variable.Kind regards.
-
Hi @Papa ,
Few days back I have the same problem. It has nothing to do with Qt. It is problem caused by the MVSC. In my machine, I have both MSVC 2013 and 2008. When I updated the MVSC 2013, it caused this issue for Qt 4.8 2008(This is only in my case). But all Qt project works fine in Visual studio with Qt plugin. I have this problem only with Qt creator with MSVC compiler. And I am sure, it has nothing to do with Qt.
- In my case, reinstalling MSVC worked perfectly. If possible, try this. I tried many but did not work except this.
- Don't need to reinstall all VS versions. Just reinstall only the compiler you have problem.In my case, i have problem with only VS 2008, I reinstalled only VS 2008.
Seems, this problem happens mostly when you have multiple MSVC's like 2008 12 13 on your machine. I have this issue on Windows10.
-> Sorry for mutliple edits for this reply.
-
@Papa
Hello,
This snippet should suit you:# This will only work on windows in any case, so specifying a platform seems redundant LIBS += -L"C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10586.0/um/x64/" -lkernel32
Why you'd want to link
kernel32
, however, is beyond my abilities to comprehend.Kind regards.
@kshegunov
I don't wanna link against anything, all I want to do is debug and/or run the program, it is Qt that needs to use the C++ linker and compiler. How it compiles and what it links to is not of my concern, as I said, all I want to do is write my program and run it, and if needed debug it.
I am a newbie, so advance programming is not for me yet. -
@Papa
Hello,
I don't understand why you didn't do as I suggested, perhaps I hadn't explained myself clearly? Your.pro
file should look something like this (note the the quoted paths):# ... Some stuff CONFIG += c++11 win32 { #< This only spares me to write win32:LIBS at every line # You must use quoted paths when they contain spaces LIBS += "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10586.0/um/x64/kernel32.lib" LIBS += "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10586.0/um/x64/shell32.lib" } # Again, use quoted paths INCLUDEPATH += "C:/Users/Del Noble/Documents/Dev/c++/jme" # ... More stuff
Here you can find more information on the
LIBS
qmake variable.Kind regards.
@kshegunov
Yes you were right, thanks so much.
However, Qt now says:
:-1: error: LNK1158: cannot run 'rc.exe'Following the pattern you showed me, I added this line to the pro file:
LIB += "C:/Program Files (x86)/Windows Kits/10/bin/x64/rc.exe"
but to no avail.How can I solve this problem, is Qt always this complicated?
Would it be easier of I use g++ instead of VC++? -
Hi @Papa ,
Copy this file from "c:\Program Files (x86)\Windows Kits\8.1\bin\x86\” to “c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\”.
Use Qt plugin in VS then you can compile all Qt work without this error. You will get compile error only in Creator. Seems it is the error caused because of different bit versions. Seems Qt misunderstood the compiler version.Reinstalling VS will fix all these errors automatically for you. It might take hardly 15 minuten. You can save lot of time.
How can I solve this problem, is Qt always this complicated?
No, Qt is very friendly than VS if you are making Qt projects. It is error from compiler.
-
Hi @Papa ,
Copy this file from "c:\Program Files (x86)\Windows Kits\8.1\bin\x86\” to “c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\”.
Use Qt plugin in VS then you can compile all Qt work without this error. You will get compile error only in Creator. Seems it is the error caused because of different bit versions. Seems Qt misunderstood the compiler version.Reinstalling VS will fix all these errors automatically for you. It might take hardly 15 minuten. You can save lot of time.
How can I solve this problem, is Qt always this complicated?
No, Qt is very friendly than VS if you are making Qt projects. It is error from compiler.
@Ni.Sumi said:
Copy this file from "c:\Program Files (x86)\Windows Kits\8.1\bin\x86\” to “c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\”.
This is bad advice. You shouldn't go around copying files to make things "work".
Use Qt plugin in VS then you can compile all Qt work without this error.
This is good advice, provided you work with visual studio.
@Papa
Are you using QtCreator? You shouldn't need to link thekernel32
,shell32
and the like, it sound as a simple configuration error. Make sure you've created a kit that matches the (presumably) downloaded Qt distribution.
Here are a few links that should help you get started:
http://doc.qt.io/qtcreator/index.html
http://doc.qt.io/qtcreator/creator-configuring.html
http://doc.qt.io/qtcreator/creator-tool-chains.html
http://doc.qt.io/qtcreator/creator-targets.html
http://doc.qt.io/qtcreator/creator-project-qmake.htmlIf you have configured everything properly you wouldn't need to link the system libraries and shouldn't have problems running the resource compiler (
rc.exe
). If you're building from the command line, then it's a different matter.I don't wanna link against anything, all I want to do is debug and/or run the program, it is Qt that needs to use the C++ linker and compiler. How it compiles and what it links to is not of my concern, as I said, all I want to do is write my program and run it, and if needed debug it.
You're wrong about this. You will be needing some basic knowledge what the compiler and linker do, possibly the loader and this has nothing to do with Qt. You, as a programmer, have to know how a program is built at least to the point to recognize what errors you get and why.
Kind regards.