Results 1 to 4 of 4

Thread: QLibrary, problem with using external dll, in release

  1. #1
    Join Date
    Nov 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default QLibrary, problem with using external dll, in release

    Hello.
    Need help.
    I try to use external dll in my application. Code is..
    Qt Code:
    1. QLibrary lib("c:/lib.dll");
    2.  
    3. if(lib.load())
    4. qDebug("\n Library is loaded \n");
    5. else
    6. qDebug ("\n Library is not loaded \n");
    7.  
    8. typedef int (*MyPrototype)(char*,char* ,char*,char*,char *);
    9. MyPrototype myFunction = (MyPrototype) lib.resolve("func");
    10.  
    11. if (myFunction){
    12. int tmp = myFunction("qwe","qwe","qwe","qwe","qwe");
    13. qDebug("Library start,tmp =%d", tmp);
    14. }
    To copy to clipboard, switch view to plain text mode 

    Function signature in the external dll is:
    int WINAPI func(const char*,const char*,const char*,const char*,const char*)

    Everything work fine if i compile my application in debug mode, but if i try to compile in release and run, program send exception "The instruction at.... The memory could not be "read"". This happens then a try call myFunction(.....). What i`m doing wrong?

    Thanks.

    PS
    Sorry for my english.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: QLibrary, problem with using external dll, in release

    Please post the full error message.

    And note that you can not use just any library this way. It's explained in the documentation.
    The correct way to use this library is to link to it and include the header files.

  3. #3
    Join Date
    Nov 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QLibrary, problem with using external dll, in release

    Full error message:
    The instruction at "0x488b386f" referenced memory at "0x00000001". The memory could not be "read".

    And note that you can not use just any library this way.
    But, in debug mode everything work!!!This means that i can use this library in that way.

    The correct way to use this library is to link to it and include the header files.
    How? Simply, add path to library into project file and include header file? But i dont have lib.a file.... this is not my lib, i'm only have lib.dll and function signature.
    Last edited by Jeddite; 11th November 2010 at 20:48.

  4. #4
    Join Date
    Nov 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QLibrary, problem with using external dll, in release

    Thanks all.

    I thix it.
    The problem was in external lib, exactly in absense of DB that use this library. When i start my application on real server everything work ok!!!

Similar Threads

  1. Debug / Release Problem
    By messifanboy in forum Newbie
    Replies: 8
    Last Post: 7th October 2009, 16:23
  2. QLibrary resolve problem
    By Nippler in forum Qt Programming
    Replies: 0
    Last Post: 4th December 2008, 15:37
  3. External Lib read from QBuffer on Calback problem
    By patrik08 in forum Qt Programming
    Replies: 2
    Last Post: 2nd June 2008, 19:43
  4. The problem with QLibrary, help me!
    By dungsivn in forum Qt Programming
    Replies: 4
    Last Post: 17th January 2008, 14:03
  5. Problem with Release version
    By jlbrd in forum Installation and Deployment
    Replies: 7
    Last Post: 30th March 2006, 19:45

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.