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. How properly add external libs to Qt .pro?
QtWS25 Last Chance

How properly add external libs to Qt .pro?

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 6 Posters 10.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.
  • E Offline
    E Offline
    Engelard
    wrote on 8 Aug 2018, 02:50 last edited by Engelard 8 Aug 2018, 02:51
    #1

    I searching in google and can't find the solution which would work. For the moment, i add to simple includes in my .h file and it gave me 146 errors.

    #include <tchar.h>
    #include <psapi.h>
    

    First, i add in to my .pro file this:

    LIBS     +=  -lpsapi
    

    It wont work, still same errors. Next suggestions from google i did'nt get at all, it suggests:

    The proper way to do this is like this:

    LIBS += -L/path/to -lpsapi

    In case you want to store your lib files in the project directory, you can reference them with the $$PRO_FILE_PWD variable, e.g.:

    LIBS += -L"$$PRO_FILE_PWD/3rdparty/libs/" -lpsapi

    That i dont get at all, what should i do? download proper .lib files of psapi, place it in that directory and then add proper path in my .pro file?

    But the hardest suggestion was from Microsoft, and it was'nt even for Qt project, but they said:

    // To ensure correct resolution of symbols, add Psapi.lib to TARGETLIBS
    // and compile with -DPSAPI_VERSION=1

    I simple C++ programmer, i never was curious about that linking creepy stuff. Help me.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 8 Aug 2018, 05:56 last edited by
      #2

      What errors are you getting? Are they linker errors or compiler errors?

      You definitely need to add library headers to INCLUDEPATH. That should solve compiler errors.

      Then if you get errors from your linker, post them here. It can be that linker can't find the library (it will simply say so then), but it can also fail to find symbols inside the library (then it will print many errors).

      (Z(:^

      E 1 Reply Last reply 8 Aug 2018, 14:40
      5
      • S sierdzio
        8 Aug 2018, 05:56

        What errors are you getting? Are they linker errors or compiler errors?

        You definitely need to add library headers to INCLUDEPATH. That should solve compiler errors.

        Then if you get errors from your linker, post them here. It can be that linker can't find the library (it will simply say so then), but it can also fail to find symbols inside the library (then it will print many errors).

        E Offline
        E Offline
        Engelard
        wrote on 8 Aug 2018, 14:40 last edited by
        #3

        @sierdzio said in How properly add external libs to Qt .pro?:

        INCLUDEPATH

        Well, i tried includepath(i found about 15 psapi.lib files on my Disk C):

        QT       += core gui
        LIBS     += -luser32
        INCLUDEPATH += C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\um\x64
        LIBS     += -lpsapi
        

        And still same errors:

        alt text

        K 1 Reply Last reply 8 Aug 2018, 15:21
        0
        • E Engelard
          8 Aug 2018, 14:40

          @sierdzio said in How properly add external libs to Qt .pro?:

          INCLUDEPATH

          Well, i tried includepath(i found about 15 psapi.lib files on my Disk C):

          QT       += core gui
          LIBS     += -luser32
          INCLUDEPATH += C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\um\x64
          LIBS     += -lpsapi
          

          And still same errors:

          alt text

          K Offline
          K Offline
          koahnig
          wrote on 8 Aug 2018, 15:21 last edited by
          #4

          @Engelard

          Your INCLUDEPATH is not properly defined. Backslahses are interpret as end of lines with continuation in next line. The spaces are inpret as separators.

          Try

          INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.16299.0/um/x64"
          

          In LIBS you specify library but not the path to where to find it. See here: https://doc.qt.io/qt-5/qmake-variable-reference.html#libs

          Vote the answer(s) that helped you to solve your issue(s)

          E 1 Reply Last reply 8 Aug 2018, 15:31
          3
          • K koahnig
            8 Aug 2018, 15:21

            @Engelard

            Your INCLUDEPATH is not properly defined. Backslahses are interpret as end of lines with continuation in next line. The spaces are inpret as separators.

            Try

            INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.16299.0/um/x64"
            

            In LIBS you specify library but not the path to where to find it. See here: https://doc.qt.io/qt-5/qmake-variable-reference.html#libs

            E Offline
            E Offline
            Engelard
            wrote on 8 Aug 2018, 15:31 last edited by
            #5

            @koahnig Still not working(even worse, 282 errors now)

            QT       += core gui
            INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.16299.0/um/x64"
            LIBS     += -luser32
            LIBS     += "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.16299.0/um/x64/Psapi.Lib"
            
            M 1 Reply Last reply 8 Aug 2018, 15:38
            0
            • E Engelard
              8 Aug 2018, 15:31

              @koahnig Still not working(even worse, 282 errors now)

              QT       += core gui
              INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.16299.0/um/x64"
              LIBS     += -luser32
              LIBS     += "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.16299.0/um/x64/Psapi.Lib"
              
              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 8 Aug 2018, 15:38 last edited by mrjj 8 Aug 2018, 16:01
              #6

              @Engelard
              Hi
              Are you using visual studio compiler and not mingw ?

              update:
              you need
              #include <windows.h>
              #include <psapi.h>

              and .pro syntax is
              INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10240.0/um/x64"
              LIBS += -lPsapi

              then it links here.

              NOTE: my path is slightly different from yours.

              E 1 Reply Last reply 8 Aug 2018, 16:11
              1
              • M mrjj
                8 Aug 2018, 15:38

                @Engelard
                Hi
                Are you using visual studio compiler and not mingw ?

                update:
                you need
                #include <windows.h>
                #include <psapi.h>

                and .pro syntax is
                INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10240.0/um/x64"
                LIBS += -lPsapi

                then it links here.

                NOTE: my path is slightly different from yours.

                E Offline
                E Offline
                Engelard
                wrote on 8 Aug 2018, 16:11 last edited by Engelard 8 Aug 2018, 16:14
                #7

                @mrjj said in How properly add external libs to Qt .pro?:

                @Engelard
                Hi
                Are you using visual studio compiler and not mingw ?

                update:
                you need
                #include <windows.h>
                #include <psapi.h>

                Your order of including trigger in me some memory what i had months before(had same issue but with includes for Opengl).

                What i now did.

                Just replace windows include before psapi and others and it now compile with no errors, perfectly as it should. Also i tested, now no additional lines in .pro file needed. so my .pro section looks like this:

                QT       += core gui
                LIBS     += -luser32
                

                So the solution: Windows.h should be included BEFORE libs which depends on it.

                A 1 Reply Last reply 8 Aug 2018, 17:31
                0
                • E Engelard
                  8 Aug 2018, 16:11

                  @mrjj said in How properly add external libs to Qt .pro?:

                  @Engelard
                  Hi
                  Are you using visual studio compiler and not mingw ?

                  update:
                  you need
                  #include <windows.h>
                  #include <psapi.h>

                  Your order of including trigger in me some memory what i had months before(had same issue but with includes for Opengl).

                  What i now did.

                  Just replace windows include before psapi and others and it now compile with no errors, perfectly as it should. Also i tested, now no additional lines in .pro file needed. so my .pro section looks like this:

                  QT       += core gui
                  LIBS     += -luser32
                  

                  So the solution: Windows.h should be included BEFORE libs which depends on it.

                  A Offline
                  A Offline
                  aha_1980
                  Lifetime Qt Champion
                  wrote on 8 Aug 2018, 17:31 last edited by
                  #8

                  @Engelard

                  So the solution: Windows.h should be included BEFORE libs which depends on it.

                  ... and sane include files include everything they need, so they don't depend on any order. which seems not the case here.

                  Qt has to stay free or it will die.

                  E 1 Reply Last reply 8 Aug 2018, 17:40
                  1
                  • A aha_1980
                    8 Aug 2018, 17:31

                    @Engelard

                    So the solution: Windows.h should be included BEFORE libs which depends on it.

                    ... and sane include files include everything they need, so they don't depend on any order. which seems not the case here.

                    E Offline
                    E Offline
                    Engelard
                    wrote on 8 Aug 2018, 17:40 last edited by
                    #9

                    @aha_1980 not always, as i said, i already saw such cases before when some libraries need inclusion of other libraries, like glfw.h and glew.h, one depends on another.

                    J 1 Reply Last reply 9 Aug 2018, 02:09
                    0
                    • E Engelard
                      8 Aug 2018, 17:40

                      @aha_1980 not always, as i said, i already saw such cases before when some libraries need inclusion of other libraries, like glfw.h and glew.h, one depends on another.

                      J Offline
                      J Offline
                      JKSH
                      Moderators
                      wrote on 9 Aug 2018, 02:09 last edited by JKSH 8 Sept 2018, 03:13
                      #10

                      @Engelard said in How properly add external libs to Qt .pro?:

                      @aha_1980 not always, as i said, i already saw such cases before when some libraries need inclusion of other libraries, like glfw.h and glew.h, one depends on another.

                      Yes, we know these scenarios exist. @aha_1980 is just pointing out that such headers are not "sane" :)

                      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                      E 1 Reply Last reply 9 Aug 2018, 02:38
                      2
                      • J JKSH
                        9 Aug 2018, 02:09

                        @Engelard said in How properly add external libs to Qt .pro?:

                        @aha_1980 not always, as i said, i already saw such cases before when some libraries need inclusion of other libraries, like glfw.h and glew.h, one depends on another.

                        Yes, we know these scenarios exist. @aha_1980 is just pointing out that such headers are not "sane" :)

                        E Offline
                        E Offline
                        Engelard
                        wrote on 9 Aug 2018, 02:38 last edited by JKSH 8 Sept 2018, 03:13
                        #11

                        Yes, we know these scenarios exist.

                        Oh, now i understand.

                        @aha_1980 is just pointing out that such headers are not "sane" :)

                        Well, maybe thats because it were made by microsoft.

                        1 Reply Last reply
                        0

                        10/11

                        9 Aug 2018, 02:09

                        • Login

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