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. Regarding the static library loading fails
Qt 6.11 is out! See what's new in the release blog

Regarding the static library loading fails

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 2 Posters 4.9k Views 2 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #4

    A static lib must be linked into the application so QLibrary cannot be used.
    (it will report error)

    • But still widget is showing.

    so WidgetApplication comes from the static lib?

    Normally it complains if cant link what you ask of it so it sounds like you are in fact using the static lib but only u can tell :)

    1 Reply Last reply
    0
    • Pradeep KumarP Offline
      Pradeep KumarP Offline
      Pradeep Kumar
      wrote on last edited by Pradeep Kumar
      #5

      Yes i have used static lib , inherited the class from QWidget. So i am calling the class name as WidgetApplication.

      so .pro file of WidgetApplication. Is below

      https://postimg.org/image/el9nd8lx9/

      Pradeep Kumar
      Qt,QML Developer

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

        Ok so it seems to use the lib ?
        So it was working :)

        1 Reply Last reply
        1
        • Pradeep KumarP Offline
          Pradeep KumarP Offline
          Pradeep Kumar
          wrote on last edited by Pradeep Kumar
          #7

          Hmmmm

          came to know when we want to allocate the memory using the libraries created , then we need to go for using the class QLibrary.
          If we use static libraries linked to out application, memory will be allocated.

          Thanks,

          Pradeep Kumar
          Qt,QML Developer

          mrjjM 1 Reply Last reply
          0
          • Pradeep KumarP Pradeep Kumar

            Hmmmm

            came to know when we want to allocate the memory using the libraries created , then we need to go for using the class QLibrary.
            If we use static libraries linked to out application, memory will be allocated.

            Thanks,

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by mrjj
            #8

            @Pradeep-Kumar
            Yes when using static lib, its 100% included into the application and you do not gain the feature on load on demand as you do
            with shared libs. So if you need to only have it active is needed - than dynamic library is better.
            Not that just linking the lib, might not use much extra as long no objects are allocated but the code is indeed
            always compiled into the app and in that way takes extra memory.

            Pradeep KumarP 1 Reply Last reply
            2
            • mrjjM mrjj

              @Pradeep-Kumar
              Yes when using static lib, its 100% included into the application and you do not gain the feature on load on demand as you do
              with shared libs. So if you need to only have it active is needed - than dynamic library is better.
              Not that just linking the lib, might not use much extra as long no objects are allocated but the code is indeed
              always compiled into the app and in that way takes extra memory.

              Pradeep KumarP Offline
              Pradeep KumarP Offline
              Pradeep Kumar
              wrote on last edited by
              #9

              @mrjj said in Regarding the static library loading fails:

              @Pradeep-Kumar
              Yes when using static lib, its 100% included into the application and you do not gain the feature on load on demand as you do
              with shared libs. So if you need to only have it active ia needed - than dynamic library is better.
              Not that just linking the lib, might not use much extra as long no objects are allocated but the code is indeed
              always compiled into the app and in that way takes extra memory.

              Just explained nicely and ellaborated my previous post answer.
              with the static lib, executable size also increases.

              Got it man.

              Pradeep Kumar
              Qt,QML Developer

              mrjjM 1 Reply Last reply
              1
              • Pradeep KumarP Pradeep Kumar

                @mrjj said in Regarding the static library loading fails:

                @Pradeep-Kumar
                Yes when using static lib, its 100% included into the application and you do not gain the feature on load on demand as you do
                with shared libs. So if you need to only have it active ia needed - than dynamic library is better.
                Not that just linking the lib, might not use much extra as long no objects are allocated but the code is indeed
                always compiled into the app and in that way takes extra memory.

                Just explained nicely and ellaborated my previous post answer.
                with the static lib, executable size also increases.

                Got it man.

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #10

                @Pradeep-Kumar
                executable size also increases.

                Indeed it does. A plain empty default project compiled with static Qt is around 15 MB as the Qt dlls are compiled into it.
                For debug builds, it can get insane big. exe > 200 MB!

                1 Reply Last reply
                2
                • Pradeep KumarP Offline
                  Pradeep KumarP Offline
                  Pradeep Kumar
                  wrote on last edited by
                  #11

                  Then if i have to use QLibrary then shared libraries comes into picture, and then only i can use it.

                  Hmmmmmmm:))))))))))

                  Pradeep Kumar
                  Qt,QML Developer

                  mrjjM 1 Reply Last reply
                  0
                  • Pradeep KumarP Pradeep Kumar

                    Then if i have to use QLibrary then shared libraries comes into picture, and then only i can use it.

                    Hmmmmmmm:))))))))))

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #12

                    @Pradeep-Kumar
                    If the lib is a Qt lib and the app that will use it - is a Qt app, I highly suggest you have a look at Qt plugins as
                    it is a smart(er?) way to use shared libs.

                    http://doc.qt.io/qt-5/qtwidgets-tools-plugandpaint-app-example.html

                    The same way Creator uses its plugins , you can use for your app and libs.

                    it uses a interface design and its easier to handle than raw loading as it helps exporting QWidgets with more in
                    a nice manner. It takes a little to get up and running but after that its pretty easy to use.

                    http://doc.qt.io/qt-5/qtwidgets-tools-echoplugin-example.html

                    1 Reply Last reply
                    2
                    • Pradeep KumarP Offline
                      Pradeep KumarP Offline
                      Pradeep Kumar
                      wrote on last edited by
                      #13

                      Hi,

                      I got the output and it is working in multiple devices.
                      Thanks for the help and guidance provided.

                      So marking as Solved.

                      Thanks,

                      Pradeep Kumar
                      Qt,QML Developer

                      1 Reply Last reply
                      1

                      • Login

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