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. The standalone Qt application fails to execute the functions in the dynamic library.
Forum Updated to NodeBB v4.3 + New Features

The standalone Qt application fails to execute the functions in the dynamic library.

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 1.7k 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.
  • NospyN Offline
    NospyN Offline
    Nospy
    wrote on last edited by A Former User
    #1

    Hi

    My PC environment is Windows XP 32bit.

    I compiled the static library of Qt 5.5.1 and then successfully build the standalone application.

    The standalone application is going to load a dynamic library via "LoadLibrary" and launch each function via "GetProcAddress".

    If I put the application into different directory, some functions of the dynamic library fails to be executed.

    Thanks for any suggestion.

    kshegunovK 1 Reply Last reply
    0
    • NospyN Nospy

      Hi

      My PC environment is Windows XP 32bit.

      I compiled the static library of Qt 5.5.1 and then successfully build the standalone application.

      The standalone application is going to load a dynamic library via "LoadLibrary" and launch each function via "GetProcAddress".

      If I put the application into different directory, some functions of the dynamic library fails to be executed.

      Thanks for any suggestion.

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      Hello @Nospy,

      If I put the application into different directory, some functions of the dynamic library fails to be executed.

      Have you tried to debug your application? Did you make sure the library is loaded and the symbols' addresses are resolved correctly by GetProcAddress? On a related note, why not link against the library instead of resolving at runtime?

      Kind regards.

      Read and abide by the Qt Code of Conduct

      NospyN 1 Reply Last reply
      1
      • kshegunovK kshegunov

        Hello @Nospy,

        If I put the application into different directory, some functions of the dynamic library fails to be executed.

        Have you tried to debug your application? Did you make sure the library is loaded and the symbols' addresses are resolved correctly by GetProcAddress? On a related note, why not link against the library instead of resolving at runtime?

        Kind regards.

        NospyN Offline
        NospyN Offline
        Nospy
        wrote on last edited by
        #3

        @kshegunov

        Thanks for your reply.

        Yes, I checked the symbols' address are correct.

        Besides, I'm worried about the implementation of the library maybe change in the future so

        resolving it at runtime and don't need to compile the application again.

        Allow me to tell more for understanding the question.

        The dynamic library has three functions, Fun_A, Fun_B and Fun_C.

        The standalone application will link the library at runtime.

        Case 1) I put the application into C:. It's fine. Fun_A, Fun_B and Fun_C can be executed.

        Case 2) I put the same application into C:\xxxxxx. Fun_A and Fun_B can be executed but Fun_C can't.

        Case 3) I revised the source code. For example, adding qDebug() to print the information. After
        recompiling the application, Fun_A can be executed but Fun_B can't.

        p.s. I confirmed again the symbol's addresses are correct in these cases.

        Thanks again.

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

          Is this dynamic library also linked to the static Qt?
          It seems its also using Qt?

          Normally with static Qt it wants plugins as static also

          http://doc.qt.io/qt-5/plugins-howto.html#static-plugins
          "Plugins can be linked statically into your application. If you build the static version of Qt, this is the only option for including Qt's predefined plugins"

          I guess this only applies to predefined plugins?

          1 Reply Last reply
          2
          • NospyN Nospy

            @kshegunov

            Thanks for your reply.

            Yes, I checked the symbols' address are correct.

            Besides, I'm worried about the implementation of the library maybe change in the future so

            resolving it at runtime and don't need to compile the application again.

            Allow me to tell more for understanding the question.

            The dynamic library has three functions, Fun_A, Fun_B and Fun_C.

            The standalone application will link the library at runtime.

            Case 1) I put the application into C:. It's fine. Fun_A, Fun_B and Fun_C can be executed.

            Case 2) I put the same application into C:\xxxxxx. Fun_A and Fun_B can be executed but Fun_C can't.

            Case 3) I revised the source code. For example, adding qDebug() to print the information. After
            recompiling the application, Fun_A can be executed but Fun_B can't.

            p.s. I confirmed again the symbol's addresses are correct in these cases.

            Thanks again.

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #5

            @Nospy said:

            Besides, I'm worried about the implementation of the library maybe change in the future so resolving it at runtime and don't need to compile the application again.

            This is why libraries are made binary compatible, plus I'm assuming you're resolving symbols with C-linkage, which is already binary compatible, so if the implementation changes you shouldn't really care

            Case 1) I put the application into C:. It's fine. Fun_A, Fun_B and Fun_C can be executed.
            Case 2) I put the same application into C:\xxxxxx. Fun_A and Fun_B can be executed but Fun_C can't.
            Case 3) I revised the source code. For example, adding qDebug() to print the information. After
            recompiling the application, Fun_A can be executed but Fun_B can't.

            By "can't be executed" you mean you get a segmentation fault? Are you sure LoadLibrary isn't loading some other version of the dll, one from the system location for example?

            Read and abide by the Qt Code of Conduct

            NospyN 1 Reply Last reply
            2
            • kshegunovK kshegunov

              @Nospy said:

              Besides, I'm worried about the implementation of the library maybe change in the future so resolving it at runtime and don't need to compile the application again.

              This is why libraries are made binary compatible, plus I'm assuming you're resolving symbols with C-linkage, which is already binary compatible, so if the implementation changes you shouldn't really care

              Case 1) I put the application into C:. It's fine. Fun_A, Fun_B and Fun_C can be executed.
              Case 2) I put the same application into C:\xxxxxx. Fun_A and Fun_B can be executed but Fun_C can't.
              Case 3) I revised the source code. For example, adding qDebug() to print the information. After
              recompiling the application, Fun_A can be executed but Fun_B can't.

              By "can't be executed" you mean you get a segmentation fault? Are you sure LoadLibrary isn't loading some other version of the dll, one from the system location for example?

              NospyN Offline
              NospyN Offline
              Nospy
              wrote on last edited by
              #6

              @kshegunov said:

              @Nospy said:

              Besides, I'm worried about the implementation of the library maybe change in the future so resolving it at runtime and don't need to compile the application again.

              This is why libraries are made binary compatible, plus I'm assuming you're resolving symbols with C-linkage, which is already binary compatible, so if the implementation changes you shouldn't really care

              Yes, you are right.

              Case 1) I put the application into C:. It's fine. Fun_A, Fun_B and Fun_C can be executed.
              Case 2) I put the same application into C:\xxxxxx. Fun_A and Fun_B can be executed but Fun_C can't.
              Case 3) I revised the source code. For example, adding qDebug() to print the information. After
              recompiling the application, Fun_A can be executed but Fun_B can't.

              By "can't be executed" you mean you get a segmentation fault? Are you sure LoadLibrary isn't loading some other version of the dll, one from the system location for example?

              Yes, I got a segmentation fault. There is only one version of the dll.

              Base on @mrjj's reply, I make a workaround solution, let the QT application to execute another application doing the job which the dll does.

              Thank a lot. @mrjj and @kshegunov

              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