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.
  • EngelardE Offline
    EngelardE Offline
    Engelard
    wrote on last edited by Engelard
    #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
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on 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(:^

      EngelardE 1 Reply Last reply
      5
      • sierdzioS sierdzio

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

        EngelardE Offline
        EngelardE Offline
        Engelard
        wrote on 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
        0
        • EngelardE Engelard

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

          EngelardE 1 Reply Last reply
          3
          • K koahnig

            @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

            EngelardE Offline
            EngelardE Offline
            Engelard
            wrote on 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"
            
            mrjjM 1 Reply Last reply
            0
            • EngelardE Engelard

              @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"
              
              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #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.

              EngelardE 1 Reply Last reply
              1
              • mrjjM mrjj

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

                EngelardE Offline
                EngelardE Offline
                Engelard
                wrote on last edited by Engelard
                #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.

                aha_1980A 1 Reply Last reply
                0
                • EngelardE Engelard

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

                  aha_1980A Offline
                  aha_1980A Offline
                  aha_1980
                  Lifetime Qt Champion
                  wrote on 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.

                  EngelardE 1 Reply Last reply
                  1
                  • aha_1980A aha_1980

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

                    EngelardE Offline
                    EngelardE Offline
                    Engelard
                    wrote on 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.

                    JKSHJ 1 Reply Last reply
                    0
                    • EngelardE Engelard

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

                      JKSHJ Offline
                      JKSHJ Offline
                      JKSH
                      Moderators
                      wrote on last edited by JKSH
                      #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

                      EngelardE 1 Reply Last reply
                      2
                      • JKSHJ JKSH

                        @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" :)

                        EngelardE Offline
                        EngelardE Offline
                        Engelard
                        wrote on last edited by JKSH
                        #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

                        • Login

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