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. Link error: can't open shell32.lib, which I added to project
Forum Updated to NodeBB v4.3 + New Features

Link error: can't open shell32.lib, which I added to project

Scheduled Pinned Locked Moved Installation and Deployment
10 Posts 5 Posters 12.2k Views 1 Watching
  • 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.
  • B Offline
    B Offline
    Benk10
    wrote on last edited by
    #1

    I'm using Qt 5.4 with Qt Creator and MSVC 12.0 as the compiler (Desktop Qt 5.4.0 MSVC2013 64bit)

    I'm new to Qt and worked through the textFinder example. When I built it, I got a linker error "can't find shell32.lib"
    This file is in the Windows SDK, so I followed the steps to "add a library":http://doc.qt.digia.com/qtcreator-2.3/creator-project-qmake-libraries.html
    and added it as a static system library, did a clean and rebuild, but got the same error again.

    Trying the same thing but including it as an external library and explicitly giving the full shell32.lib path and the includes directory for the Windows SDK also failed.

    What gives?

    Also, I'm not so clear on what an "internal library" is. The description there says it adds a library in your build tree. But if the library is already in the build tree, then why do you have to add it?

    It occurred to me that perhaps the Qt Creator needs file permissions to open this file. If so, how do I grant them?

    Any help is much appreciated!

    1 Reply Last reply
    0
    • hskoglundH Offline
      hskoglundH Offline
      hskoglund
      wrote on last edited by
      #2

      Hi, actually shell32.lib should be difficult to get rid of (not the other way around :-). What I mean is, every Qt app you build on Windows uses shell32.lib.

      For example, a simple test of shell32.lib is to display the same dialog box that is shown when type winver in a CMD window:

      1. Create a new Widgets app.
      2. in mainwindow.cpp. add #include "windows" after #include "ui_mainwindow.h"
      3. also in mainwindow.cpp, after ui->setupUi(this); add this line:
        @
        ShellAbout(NULL,QString("Hello from Qt").toStdWString().c_str(),NULL,NULL);
        @
        Now run the app, the dialog box from Windows is shown, or?
      1 Reply Last reply
      0
      • B Offline
        B Offline
        Benk10
        wrote on last edited by
        #3

        That's interesting, but it doesn't really answer my question. The problem, again, is that the linker fails to find/open shell32.lib even when I explicitly add it to the libraries for my project. So I think something may not be configured correctly but I don't know what.

        FWIW, see the last post on "this thread":http://qt-project.org/forums/viewthread/23763
        I have both the windows 7 and 8 SDKs. The Windows 8 SDKs are installed in a folder called Windows Kits. I still fail to open shell32.lib with the 8.0 SDK, for both the x64 and x86 versions. And the Qt Creator program has full rights since I am running as admin. There is no LIB environment variable set on my system.

        I have also tried using quotes because the file path has spaces in it, "as under LIBS here":https://qt-project.org/doc/qt-4.7/qmake-variable-reference.html
        but also to no avail.

        The code looks like this:
        @win32:CONFIG(release, debug|release): LIBS += $$quote(C:/Program Files (x86)/Windows Kits/8.0/Lib/win8/um/x64/shell32.lib)
        else:win32:CONFIG(debug, debug|release): LIBS += $$quote(C:/Program Files (x86)/Windows Kits/8.0/Lib/win8/um/x64/shell32.lib)

        INCLUDEPATH += $$quote(C:/Program Files (x86)/Windows Kits/8.0/Include)
        DEPENDPATH += $$quote(C:/Program Files (x86)/Windows Kits/8.0/Include)
        @

        But remember, I still get "cannot open shell32.lib" even without this code. It's as if this code to add the library does nothing at all.

        1 Reply Last reply
        0
        • hskoglundH Offline
          hskoglundH Offline
          hskoglund
          wrote on last edited by
          #4

          Hmm, on my computer (Win7 SP1 64-bit, MSVC2013 Update 4 and Qt 5.4) Qt uses the shell32.lib in the Windows Kit 8.1 folder (C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x64). Not the 8.0 folder :-(
          If I remove shell32.lib from my 8.1 folder Qt gives me the same LNK1104 error as you get.

          To see if your Qt installation is broken or not, that's why I suggested a simple test as in my previous post, if you get the LNK1104 error for that program, then next step would be to look at your MSVC2013 installation.

          1 Reply Last reply
          0
          • B Offline
            B Offline
            Benk10
            wrote on last edited by
            #5

            On my computer, the shell32.lib is in the 8.0 folder (I also have the Windows 7 SDK, which is in Windows SDKS/7,0A). The 8.1 folder has only a few files.
            Anyway, what difference does it make where the lib is? It's the same file.

            I have used my MSVC installation before, linking to Windows 7 SDK libraries.. I don't believe it has been updated but it works fine.

            I'll try your test, though.

            UPDATE
            Can't find "windows.h" This also happened when I attempted to compile and run one of the examples.
            Ugh.
            To clarify, that line you asked me to write, with the ShellAbout function, goes in the constructor after ui->setupUi(this)? What does it do?

            1 Reply Last reply
            0
            • B Offline
              B Offline
              Benk10
              wrote on last edited by
              #6

              Fixed this a while back. The issue was that including headers in the .pro file is not enough (I was under the impression that it was). The relevant libraries also need to be added in the project settings.

              1 Reply Last reply
              0
              • P Offline
                P Offline
                Papa
                wrote on last edited by
                #7

                Thanks Benk10 for the input. However, could you please show the line to add to the .pro file? In my case, since I am using Win10, my shell32.lib is located in the folder called 'C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10586.0\um\x64'

                Thanks so much for the help.

                P 1 Reply Last reply
                0
                • P Papa

                  Thanks Benk10 for the input. However, could you please show the line to add to the .pro file? In my case, since I am using Win10, my shell32.lib is located in the folder called 'C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10586.0\um\x64'

                  Thanks so much for the help.

                  P Offline
                  P Offline
                  Psunshine
                  wrote on last edited by
                  #8

                  @Papa Hello.
                  I also met this problem today.But I can't find this file under'C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10586.0\um\x64'.I tried reinstall WDK,however it's useless.I'm still looking for solution.

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    Papa
                    wrote on last edited by Papa
                    #9

                    Go to PowerShell, or cmd, and type this
                    dir C:\Program" "Files" (x86)"\Windows" "Kits\10\Lib\10.0.10586.0\um\x64\shell32.lib > C:\tmp\shell32_lib_verification.txt

                    Open the file created; you should have something like this

                    Directory: C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10586.0\um\x64

                    Mode LastWriteTime Length Name
                    -a---- 2015-11-19 9:04 PM 260368 shell32.lib

                    Keep posting, for good or bad, the forum will do its best to help you.

                    1 Reply Last reply
                    0
                    • oliiixO Offline
                      oliiixO Offline
                      oliiix
                      wrote on last edited by oliiix
                      #10
                      This post is deleted!
                      1 Reply Last reply
                      0

                      • Login

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