Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. :-1: error: LNK1104: cannot open file 'kernel32.lib'
QtWS25 Last Chance

:-1: error: LNK1104: cannot open file 'kernel32.lib'

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
12 Posts 3 Posters 8.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Papa
    wrote on 13 Feb 2016, 15:13 last edited by
    #2

    by the way, my .pro looks like this:

    QT += core
    QT -= gui

    CONFIG += 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++/abc

    TARGET = JME_Test
    CONFIG += console
    CONFIG -= app_bundle

    TEMPLATE = app

    SOURCES += main.cpp

    K 1 Reply Last reply 13 Feb 2016, 15:24
    0
    • P Papa
      13 Feb 2016, 15:13

      by the way, my .pro looks like this:

      QT += core
      QT -= gui

      CONFIG += 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++/abc

      TARGET = JME_Test
      CONFIG += console
      CONFIG -= app_bundle

      TEMPLATE = app

      SOURCES += main.cpp

      K Offline
      K Offline
      kshegunov
      Moderators
      wrote on 13 Feb 2016, 15:24 last edited by kshegunov
      #3

      @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.

      Read and abide by the Qt Code of Conduct

      P 1 Reply Last reply 14 Feb 2016, 17:39
      0
      • P Offline
        P Offline
        Papa
        wrote on 13 Feb 2016, 16:56 last edited by
        #4

        Thanks kshegunov, now my pro looks like this:
        QT += core
        QT -= gui

        CONFIG += 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++/jme

        TARGET = JME_Test
        CONFIG += console
        CONFIG -= app_bundle

        TEMPLATE = app

        SOURCES += main.cpp

        ---- However, I am still getting the same error.

        K 1 Reply Last reply 13 Feb 2016, 17:10
        0
        • P Papa
          13 Feb 2016, 16:56

          Thanks kshegunov, now my pro looks like this:
          QT += core
          QT -= gui

          CONFIG += 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++/jme

          TARGET = JME_Test
          CONFIG += console
          CONFIG -= app_bundle

          TEMPLATE = app

          SOURCES += main.cpp

          ---- However, I am still getting the same error.

          K Offline
          K Offline
          kshegunov
          Moderators
          wrote on 13 Feb 2016, 17:10 last edited by
          #5

          @Papa
          Hello,
          You either use WIN32:LIBS or LIBS 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.

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          0
          • P Offline
            P Offline
            Papa
            wrote on 13 Feb 2016, 18:12 last edited by
            #6

            OK, now it looks like this:
            QT += core
            QT -= gui

            CONFIG += 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++/jme

            TARGET = JME_Test
            CONFIG += console
            CONFIG -= app_bundle

            TEMPLATE = app

            SOURCES += main.cpp

            --- However, the problem remains

            K 1 Reply Last reply 13 Feb 2016, 18:25
            0
            • P Papa
              13 Feb 2016, 18:12

              OK, now it looks like this:
              QT += core
              QT -= gui

              CONFIG += 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++/jme

              TARGET = JME_Test
              CONFIG += console
              CONFIG -= app_bundle

              TEMPLATE = app

              SOURCES += main.cpp

              --- However, the problem remains

              K Offline
              K Offline
              kshegunov
              Moderators
              wrote on 13 Feb 2016, 18:25 last edited by
              #7

              @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.

              Read and abide by the Qt Code of Conduct

              P 1 Reply Last reply 14 Feb 2016, 18:00
              0
              • N Offline
                N Offline
                Ni.Sumi
                wrote on 13 Feb 2016, 20:55 last edited by Ni.Sumi
                #8

                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.

                1 Reply Last reply
                0
                • K kshegunov
                  13 Feb 2016, 15:24

                  @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.

                  P Offline
                  P Offline
                  Papa
                  wrote on 14 Feb 2016, 17:39 last edited by
                  #9

                  @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.

                  1 Reply Last reply
                  0
                  • K kshegunov
                    13 Feb 2016, 18:25

                    @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.

                    P Offline
                    P Offline
                    Papa
                    wrote on 14 Feb 2016, 18:00 last edited by
                    #10

                    @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++?

                    1 Reply Last reply
                    0
                    • N Offline
                      N Offline
                      Ni.Sumi
                      wrote on 14 Feb 2016, 21:54 last edited by
                      #11

                      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.

                      K 1 Reply Last reply 15 Feb 2016, 03:24
                      0
                      • N Ni.Sumi
                        14 Feb 2016, 21:54

                        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.

                        K Offline
                        K Offline
                        kshegunov
                        Moderators
                        wrote on 15 Feb 2016, 03:24 last edited by kshegunov
                        #12

                        @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 the kernel32, 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.html

                        If 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.

                        Read and abide by the Qt Code of Conduct

                        1 Reply Last reply
                        0

                        11/12

                        14 Feb 2016, 21:54

                        • Login

                        • Login or register to search.
                        11 out of 12
                        • First post
                          11/12
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved