Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem using Windows library in Qt
QtWS25 Last Chance

Problem using Windows library in Qt

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 4.1k 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.
  • S Offline
    S Offline
    SamuelYKC
    wrote on last edited by
    #1

    When I compile my projects, "LNK2019: unresolved external symbol" appears. Function names like GetPixel, GetDC, ReleaseDC, SetCursorPos appear so I am sure it is to do with the Windows library.

    The project itself shouldn't have problem. I think it is because I have recently reinstalled Qt. What should I do to resolve this issue?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ckakman
      wrote on last edited by
      #2

      Hi,

      The error message you have given is very generic. If the function names you mentioned appear in the error messages, then those function names doesn't look like Qt's. Qt's classes start with Q, functions with q and member functions with lower-case letters. You need to link to the library that contains those functions.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SamuelYKC
        wrote on last edited by
        #3

        Thanks. But still I don't know how should I perform it.

        I tried to copy to files in "Microsoft Visual Studio 12.0\VC\lib" and paste them in "Qt\5.4\msvc2013\lib" and "Qt\5.4\msvc2013_64\lib" respectively.

        When I compile my project with Qt 5.4.0 MSVC 2013 32bit, the linking errors are still there. And with Qt 5.4.0 MSVC 2013 64bit, the errors reduced to one new error: LNK1112: module machine type 'X86' conflicts with target machine type 'x64'.

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          you need to specifiy explicitly against which windows libs you want to link.
          This can e.g. be done in your .pro file. If you've already done it and wondering why it's not working then rerun qmake on it.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SamuelYKC
            wrote on last edited by
            #5

            So, I added the following codes to the .pro:

            @LIBS += -L"J:/Program Files (x86)/Windows Kits/8.1/Lib/winv6.3/um/x64"

            OTHER_FILES +=
            kernel32.lib
            user32.lib
            gdi32.lib
            winspool.lib
            comdlg32.lib
            advapi32.lib
            shell32.lib
            ole32.lib
            oleaut32.lib
            uuid.lib
            odbc32.lib
            odbccp32.lib@

            Nothing changed when I build it with Qt 5.4.0 MSVC 2013 64bit.
            And more link errors appeared when I build with Qt 5.4.0 MSVC 2013 32bit...
            What should I do???

            1 Reply Last reply
            0
            • raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              OTHER_FILES doesn't correspond to the linked libs!
              Also it shouldn't be necessary to specify the full path to the libs, since they should already be known to the compiler.

              Read "this":http://doc.qt.digia.com/qtcreator-2.1/creator-project-qmake-libraries.html to let QtCreator do the work.

              Or do the following changes (and rerun qmake afterwards):
              @
              LIBS += -lkernel32 -lkernel32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32
              @

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SamuelYKC
                wrote on last edited by
                #7

                [quote author="raven-worx" date="1422265475"]OTHER_FILES doesn't correspond to the linked libs!
                Also it shouldn't be necessary to specify the full path to the libs, since they should already be known to the compiler.

                Read "this":http://doc.qt.digia.com/qtcreator-2.1/creator-project-qmake-libraries.html to let QtCreator do the work.

                Or do the following changes (and rerun qmake afterwards):
                @
                LIBS += -lkernel32 -lkernel32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32
                @[/quote]

                OH!!! Thanks! Thanks! You saved my day!

                Your method works. But there is a mistake, you typed -lkernel32 twice and missed -luser32. Nevertheless, you have pointed the way for me. Thanks!

                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