Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Solved Use of a DLL written in Delphi Xe2

    General and Desktop
    library
    4
    7
    2060
    Loading More Posts
    • 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.
    • Zoptune
      Zoptune last edited by

      Hi,

      I have to use functions from a Delphi Xe2 DLL and i'm having some troubles.

      I use QLibrary to dynamically load the DLL at run time. All the functions are found in the DLL by the resolve function but when i call the first function (init function) my app crashes and exit with code 0.

      Maybe the problem comes from my function prototypes definition :

      typedef int (WINAPI *Init_ptr) ();
      

      In the doc :
      "Function Init : integer ; stdcall "
      return 0 if no error

      It's the first time i'm using a library (moreover in Delphi) so i don't know where is the problem.

      Any help/explanation about my problem or about DLL in general will be useful.

      Thx

      jsulm 1 Reply Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion @Zoptune last edited by

        @Zoptune Did you verify that Init_ptr actually points to the function?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        Zoptune 1 Reply Last reply Reply Quote 0
        • Zoptune
          Zoptune @jsulm last edited by

          @jsulm Yes... i think ^^

          typedef int (WINAPI *Init_ptr) ();
          
          Init_ptr Init=NULL;
          if(lib->load()){
              Init=(Init_ptr)lib->resolve("Init");
          }
          if(Init!=NULL){
              int res=Init();  // The app crashes here
          }
          

          Am I doing something wrong ?

          jsulm kshegunov 2 Replies Last reply Reply Quote 0
          • jsulm
            jsulm Lifetime Qt Champion @Zoptune last edited by

            @Zoptune Looks good. Do you have a stack trace?

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 2
            • kshegunov
              kshegunov Moderators @Zoptune last edited by

              @Zoptune
              By the way, is there a special reason for not leaving the OS loader to resolve the symbols instead of explicitly doing it with QLibrary?

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply Reply Quote 1
              • lemmel
                lemmel last edited by lemmel

                @Zoptune
                Your doc doesn't seems to be helpful.

                Are you sure that this library is operational with your build ? I know that Windows doesn't like to mix library build mixed (one with CRT of Visual Studio 2003, with another library using the crt of Visual Studio 2015).

                Furthermore « crash » is not helpful, because the cause of the crash maybe intern to your library (i.e. you make a good call, but the library doesn't initialize well); don't you have an error message/code ?

                Did you test to load that library with a regular and plain hello world in visual studio ?

                Hope all my questions will help you.

                P.S. : I suppose that you don't have the code of the library but must use it ? Can't you ask the support an C++ example ?

                1 Reply Last reply Reply Quote 1
                • Zoptune
                  Zoptune last edited by

                  @jsulm
                  @kshegunov
                  @lemmel

                  Thx all for your replys. The problem came from inside the function of the DLL.

                  In fact, the library allow me to do some task on a machine.
                  This machine is connected to my LAN.

                  The problem was that the machine has a fixed IP address and this IP was out of my LAN.
                  Had to use Wireshark to find the problem ^^

                  Thx for help :)

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post