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. Pro file configuration for using a static lib

Pro file configuration for using a static lib

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

    Hello,

    I have two projects, one is a lib file I included staticly in my other project.
    I want to do different things depending on OS, but too on Compiler.

    Here is the current code for the .a lib :
    @
    win32:CONFIG(release, debug|release): LIBS += -L../../QtWebsocket/release/ -lQtWebsocket
    else:win32:CONFIG(debug, debug|release): LIBS += -L../../QtWebsocket/debug/ -lQtWebsocket
    else:unix:!symbian: LIBS += -L../../QtWebsocket/ -lQtWebsocket

    win32:CONFIG(release, debug|release): PRE_TARGETDEPS += ../../QtWebsocket/release/libQtWebsocket.a
    else:win32:CONFIG(debug, debug|release): PRE_TARGETDEPS += ../../QtWebsocket/debug/libQtWebsocket.a
    else:unix:!symbian: PRE_TARGETDEPS += ../../QtWebsocket/libQtWebsocket.lib
    @

    And here the code for the .lib file :
    @
    win32:CONFIG(release, debug|release): LIBS += -L../../QtWebsocket/release/ -lQtWebsocket
    else:win32:CONFIG(debug, debug|release): LIBS += -L../../QtWebsocket/debug/ -lQtWebsocket
    else:unix:!symbian: LIBS += -L../../QtWebsocket/ -lQtWebsocket

    win32:CONFIG(release, debug|release): PRE_TARGETDEPS += ../../QtWebsocket/release/QtWebsocket.lib
    else:win32:CONFIG(debug, debug|release): PRE_TARGETDEPS += ../../QtWebsocket/debug/QtWebsocket.lib
    else:unix:!symbian: PRE_TARGETDEPS += ../../QtWebsocket/libQtWebsocket.lib
    @

    I wanted to know how I can improve my pro file to make it working in any configuration ?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @
      CONFIG+=staticlib
      @

      is enough in most situations.

      (Z(:^

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Maybe something like:
        @EXTENSION =
        LIBPATH =
        win32 {
        EXTENSION = lib
        CONFIG(release, debug|release) {
        LIBPATH = release
        } else {
        LIBPATH = debug
        }
        } else:unix:!symbian:EXTENSION=a

        LIBS += -L../../QtWebsocket/$$LIBPATH -lQtWebsocket
        PRE_TARGETDEPS += ../../QtWebsocket/$$LIBPATH/libQtWebsocket.$$EXTENSION
        @

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • A Offline
          A Offline
          antlafarge
          wrote on last edited by
          #4

          OK, but in windows, the extension depends of the compilater. With QtCreator, I obtain a .a file, and with visual studio, I obtain a .lib file. You can I do that ?

          1 Reply Last reply
          0
          • sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #5

            So you are compiling with 2 different compilers. Their linkers should understand the extensions and add them automatically (after -lyourLibName call). Libs will not be binary compatible anyway.

            (Z(:^

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              QtCreator will use the compiler that goes with the Qt you have selected, either mingw or msvc, it's up to you to choose which one to use.

              You have also more precise scopes if you need (IIRC win32-msvc for example)

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • A Offline
                A Offline
                antlafarge
                wrote on last edited by
                #7

                ok, thanks, that's what I searched :)

                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