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. [split] dll issues

[split] dll issues

Scheduled Pinned Locked Moved General and Desktop
13 Posts 4 Posters 5.2k 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.
  • I Offline
    I Offline
    Indrajeet
    wrote on last edited by
    #1

    Hi

    I have created a dll in win32 in which i have also linked Qt libraries so that I can use both QT & win32 datatypes in this dll.
    I have created one more QT Application in which I am loading this dll dynamically using QLibrary::load().
    After loading I am calling one function in for loop form this dll which takes QStirng as parameter for 1st 10 times the QString value which I am sending from QT app to that dll is recieved correctly in that dll function but exactly from 11th time the QString value sent from QT appp to dll function is showing garbage value?

    How to resolve this?

    1 Reply Last reply
    0
    • I Offline
      I Offline
      Indrajeet
      wrote on last edited by
      #2

      Hi

      The error message which i recieve says something like this

      A buffer overrun has occurred in TEMP.exe which has corrupted the program's internal state. Press Break to debug the program or Continue to terminate the program.

      For more details please see Help topic 'How to debug Buffer Overrun Issues'.

      1 Reply Last reply
      0
      • I Offline
        I Offline
        Indrajeet
        wrote on last edited by
        #3

        Hi Lukas

        I am facing one more problem can you help me to resolve this

        Step 1: I have created a win32 dll with name Temp.dll in which i have linked QT libraries & also added required include files so that i can also use QT datatypes in that dll.
        In Temp.dll has one function with following prototype & definition
        @
        QString Data(QString data)
        {
        return data;
        }
        @

        Step 2: Now I have created one Sample QT Appplication code for same is given below but when I am trying to call the above function in this application in for loop
        after 2-3 iterations of for loop it is crashing & giving following error message

        A buffer overrun has occurred in LoadLibrary.exe which has corrupted the program's internal state. Press Break to debug the program or Continue to terminate the program.

        For more details please see Help topic 'How to debug Buffer Overrun Issues'.

        @Sample App Code:

        #include <QLibrary>
        #include <QString>
        #include <qdebug.h>

        //Function Pointers
        typedef QString (*Data)(QString);

        int main(int argc, char *argv[])
        {
        QCoreApplication a(argc, argv);
        bool bLoaded = false;
        //Load win32 Export Library
        QLibrary lib("Temp.dll");
        bLoaded = lib.load();
        Data data= (Data) lib.resolve("Data");
        if(bLoaded)
        {
        for(int i = 0;i<100; i++)
        {
        QString strName = "Test";
        if(lib.isLoaded())
        QString strTagInfo = data(strName);
        }
        }
        else
        {
        QString str = "Failed to load Temp library";
        }
        bool bUnLoad = lib.unload();

            return a.exec&#40;&#41;; 
        

        } @

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tobias.hunger
          wrote on last edited by
          #4

          I just split this out of another thread to make the issue more visible. Hope this helps getting it resolved fast.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tobias.hunger
            wrote on last edited by
            #5

            I would guess that your buffer overrun corrupts the string you pass. Fix the overrun and your problem should go away.

            1 Reply Last reply
            0
            • L Offline
              L Offline
              lgeyer
              wrote on last edited by
              #6

              ... and merge with http://developer.qt.nokia.com/forums/viewthread/13631/ please ;-)

              1 Reply Last reply
              0
              • I Offline
                I Offline
                Indrajeet
                wrote on last edited by
                #7

                How to fix over run.

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  tobias.hunger
                  wrote on last edited by
                  #8

                  Check http://en.wikipedia.org/wiki/Buffer_overflow for more information on what is going wrong.

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    giesbert
                    wrote on last edited by
                    #9

                    If I read the code, it is buggy:

                    @
                    Sample App Code:

                    #include <QLibrary>
                    #include <QString>
                    #include <qdebug.h>
                     
                    //Function Pointers
                    typedef QString (*Data)(QString);
                     
                    int main(int argc, char *argv[])
                    {
                            // ...
                            Data  data= (Data) lib.resolve("Data");
                            if(bLoaded)
                            {
                                // ....
                                  QString strTagInfo = Data(strName);
                                  // here you use the type, not the pointer?
                            }
                            // ...
                            return a.exec&#40;&#41;;
                    }
                    

                    @

                    I would recommend to rename the pointer data to something like dataFkt or similar, so such things are seen earlier...

                    Nokia Certified Qt Specialist.
                    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                    1 Reply Last reply
                    0
                    • I Offline
                      I Offline
                      Indrajeet
                      wrote on last edited by
                      #10

                      Hi Gerolf

                      I didnt exactly get what you want me to do can you please explain clearly.

                      1 Reply Last reply
                      0
                      • I Offline
                        I Offline
                        Indrajeet
                        wrote on last edited by
                        #11

                        Hi Gerolf

                        That was the typing mistake in actual I was using data() only. But still same problem.

                        1 Reply Last reply
                        0
                        • I Offline
                          I Offline
                          Indrajeet
                          wrote on last edited by
                          #12

                          Can anyone please help me to resolve this.

                          1 Reply Last reply
                          0
                          • L Offline
                            L Offline
                            lgeyer
                            wrote on last edited by
                            #13

                            Well, you might provide a small, compilable example that reproduces your problem, which can be downloaded somewhere.

                            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