QLibrary, wine and external DLL
Greetings, I've created an external DLL for pinging remote hosts, because Qt doesn't have any ping methods.
I load it with QLibrary the following way:
Header file:
Code:
typedef float (*sendPing)(char *ip,int size,int timeout)
...
{
Q_OBJECT
...
sendPing pinger;
and in my CPP file:
Code:
...
pinger = (sendPing
) QLibrary::resolve("libICMP",
"libIcmpSendEcho");
...
if (!pinger
) { QMessageBox::critical(this,
"Error",
"Unable to load libIcmpSendEcho function!");
return;
} else { pinger("127.0.0.1",32,100); }
I'm compiling the program and testing under wine and it works fine, but when run the application under Windows with libICMP.dll in the program directory it fails with the QMessage box appearing. I can't see a reason why does it work under wine and not under native windows... Thank you for all replies!
Re: QLibrary, wine and external DLL
Firstly, separate loading the library (QLibrary::QLibrary() orQLibrary::load() and QLibrary::isLoaded()) from resolving the name so you know which bit is failing. Make sure the DLL is in the directory you think it is: check using QFile::exists(QCoreApplication::applicationDirPath () + "/libICMP.dll")
BTW: You are declaring a pointer to a function that returns a float and then ignoring the return value. Deliberate?
Re: QLibrary, wine and external DLL
Thanks. The problem was the library itself; it was compiled with Microsoft Visual C++ Express 2010, so it needed msvcr100.dll which is not on Windows XP by default (it gets in win7 with automatic updates i think), and since my wine installation has that file, it's all good.
p.s. this is example code, in my real app the results from pinger populate an array of floats which then are used to draw a realtime plot with the Qwt Library.
p.s.2 where is the [solved] button ?