Results 1 to 4 of 4

Thread: How to resolve QLibrary issue

  1. #1
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to resolve QLibrary issue

    Hi,

    I have a dll that can't re-enter, that is, it is not thread safe. But I need to call it repeatedly and it takes a lot of CPU time. So I am trying to use QtConcurrent and QLibrary.

    However, QLibrary opens same dll and shares among themself. How can I make them not share?

    The attached code gives same "addTo" and "getResult", and final results are wrong.

    addTo = 0x7fcf487e063c, getResult = 0x7fcf487e0654
    addTo = 0x7fcf487e063c, getResult = 0x7fcf487e0654
    addTo = 0x7fcf487e063c, getResult = 0x7fcf487e0654
    addTo = 0x7fcf487e063c, getResult = 0x7fcf487e0654
    addTo = 0x7fcf487e063c, getResult = 0x7fcf487e0654

    Any solution?

    Thanks!
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to resolve QLibrary issue

    Quote Originally Posted by lni View Post
    How can I make them not share?
    You can't. That's the idea of having a shared library that there is one instance of it.

    Any solution?
    Perform calculations in separate processes or make the library re-entrant and thread-safe (the terms are not the same).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to resolve QLibrary issue

    Quote Originally Posted by wysota View Post
    You can't. That's the idea of having a shared library that there is one instance of it.


    Perform calculations in separate processes or make the library re-entrant and thread-safe (the terms are not the same).
    I can't change the dll codes. It is a huge messy mathematical program.

    But how I can I do calculations in separate processes? If I make an exe out of it. I would have to call it 1000000 times (with initialization as well), that would be even slower...


    Added after 25 minutes:


    Here is my findings: for each thread, I copy the dll to a new name, open with QLibrary, then immediately delete it. The result appears to be good. See the attached codes.

    Is there any potential problem here?

    Thanks!
    Attached Files Attached Files
    Last edited by lni; 28th August 2014 at 19:37.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to resolve QLibrary issue

    Quote Originally Posted by lni View Post
    But how I can I do calculations in separate processes? If I make an exe out of it. I would have to call it 1000000 times
    No, not really. You'd have to call it as many times as you want operations to run in parallel. Each such instance would do many calculations in sequence.

    (with initialization as well), that would be even slower...
    Did you test it?

    Here is my findings: for each thread, I copy the dll to a new name, open with QLibrary, then immediately delete it. The result appears to be good. See the attached codes.
    That's really... no, sorry, I just have to say it.... that's really stupid.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. How to resolve this error in Windows 8?
    By Gokulnathvc in forum Newbie
    Replies: 3
    Last Post: 28th February 2013, 06:32
  2. QLibrary::resolve() crash on return
    By gib in forum Qt Programming
    Replies: 3
    Last Post: 29th March 2010, 09:06
  3. QLibrary resolve problem
    By Nippler in forum Qt Programming
    Replies: 0
    Last Post: 4th December 2008, 15:37
  4. Unable to resolve the IP address. ( Qt 3.)
    By joseph in forum Qt Programming
    Replies: 18
    Last Post: 5th July 2007, 12:02
  5. Can somebody resolve this issue???
    By im_rajya in forum Qt Programming
    Replies: 1
    Last Post: 20th December 2006, 10:37

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.