PDA

View Full Version : QLibrary, problem with using external dll, in release



Jeddite
11th November 2010, 11:48
Hello.
Need help.
I try to use external dll in my application. Code is..

QLibrary lib("c:/lib.dll");

if(lib.load())
qDebug("\n Library is loaded \n");
else
qDebug ("\n Library is not loaded \n");

typedef int (*MyPrototype)(char*,char* ,char*,char*,char *);
MyPrototype myFunction = (MyPrototype) lib.resolve("func");

if (myFunction){
int tmp = myFunction("qwe","qwe","qwe","qwe","qwe");
qDebug("Library start,tmp =%d", tmp);
}

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.

tbscope
11th November 2010, 14:41
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.

Jeddite
11th November 2010, 20:38
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.

Jeddite
12th November 2010, 09:24
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!!!