[SOLVED] DLL library loading problems.
-
Hi
I've been trying to load a DLL in Qt for a while, but I keep having problems while doing it (this in WinXP). The DLL comes with its respecte LIB file, therefore I'm just using a line in the project file as follows:
@LIBS += D:/QT/testOPCLibCmd/WTclient.lib@
When I run the mock project (just calling a function from the library and printing some COUTs) sometimes it goes without problems and if it runs, when I change something to the codes (such as adding another COUT statement), I get an error such as "testOPCLibCmd.exe exited with code -1073741515".
If then, I change the library definition to:
@LIBS += -LD:/QT/testOPCLibCmd
LIBS += -lWTclient.lib@and try to recompile, it works again ... until I modify my code, then I get an error
@:: error: cannot find -lWTclient.lib
:: error: collect2: ld returned 1 exit status@And it continues like that, therefore I would like to as if anyone has a suggestion of what may be the problem ? The library works without a problems in VC++ , so I guess is just my ignorance of some detail, I'm posting below the toy code that I'm using to reproduce the problem.
Thanks
@
int main(int argc, char *argv[])
{
cout<<WTclientRevision()<<endl; //Using the library to show the revision number
cout<<WTclientCoInit()<<endl; //Initializing code from library
WTclientCoUninit(); //Uninitialize library code
cin.get();
cout<<"problems"; //Taking this statment in an out breaks/fix library loading
return 0;
}
@ -
Try omitting the .lib extension:
@LIBS += -lWTclient@
qmake is probably smart enough to handle the .lib extension, but ye never know. The error code suggests that you need to add the required dll to the search path (which is either PATH + current directory afaik).
-
I knew it was a little detail that scaped me ! The .DLL is together with the .LIB file in the directory project, therefore was very strange that sometimes "it was there" and others was not.
I changes as you suggested the library loading in the .PRO file to:
@
LIBS += -LD:\QT\testOPCLibCmd
LIBS += -lWTclient
@And have been able to run my project and make some changes, so far has not failed to recompile as before. I also wonder if it had something to do with the forward slashes.
Thanks a lot Franzk!