Results 1 to 3 of 3

Thread: QLibrary, wine and external DLL

  1. #1
    Join Date
    May 2010
    Location
    Rousse, Bulgaria
    Posts
    25
    Thanks
    9
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question 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:
    Qt Code:
    1. typedef float (*sendPing)(char *ip,int size,int timeout)
    2. ...
    3. class MyClass : public QWidget
    4. {
    5. Q_OBJECT
    6. ...
    7. sendPing pinger;
    To copy to clipboard, switch view to plain text mode 
    and in my CPP file:
    Qt Code:
    1. ...
    2. pinger = (sendPing) QLibrary::resolve("libICMP","libIcmpSendEcho");
    3. ...
    4. if (!pinger) { QMessageBox::critical(this, "Error", "Unable to load libIcmpSendEcho function!"); return; }
    5. else { pinger("127.0.0.1",32,100); }
    To copy to clipboard, switch view to plain text mode 
    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!

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default 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?

  3. The following user says thank you to ChrisW67 for this useful post:

    Axtroz (9th February 2012)

  4. #3
    Join Date
    May 2010
    Location
    Rousse, Bulgaria
    Posts
    25
    Thanks
    9
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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 ?

Similar Threads

  1. QLibrary, problem with using external dll, in release
    By Jeddite in forum Qt Programming
    Replies: 3
    Last Post: 12th November 2010, 09:24
  2. How to use QLibrary?
    By digog in forum Newbie
    Replies: 22
    Last Post: 5th November 2010, 18:01
  3. Using Qt Creator under Wine in Linux?
    By kevinchannon in forum Qt Tools
    Replies: 5
    Last Post: 16th April 2010, 16:10
  4. QODBC on Wine LINUX not connect
    By patrik08 in forum Qt Programming
    Replies: 3
    Last Post: 2nd May 2007, 13:42
  5. Qlibrary
    By rianquinn in forum Qt Programming
    Replies: 5
    Last Post: 4th February 2006, 12:23

Tags for this Thread

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.