A program built with two kits works differently
-
Greetings everyone!
I have encountered a problem which I cannot solve due to high lack of experience with such cases.
I have developed an app which is built with a help of two kits - one static msvc 5.15.2 and the other dynamic mingw 6.3.0.
Both .exe files seems to work but the troubles begin when I start to use a dll library (developed by me and built with release dynamic mingw 6.3.0).
The library is used with the help of QLibrary. Nothing special - it just sends UDP datagrams by Qtimer timeouts.
So the library successfully loads in both cases but the timer do not start when static exe is used.
Also I do get a message @QObject::startTimer: QTimer can only be used with threads started with QThread@.Can anybody help me with this please?
With respect,
Alexander -
@IRBaboon said in A program built with two kits works differently:
Also I do get a message @QObject::startTimer: QTimer can only be used with threads started with QThread@.
Can anybody help me with this please?Use a debugger, install a qt message handler and see where the messages comes from by setting a breakpoint in the message handler and inspecting the call stack.
-
As far as I digged into this problem I have detected two issues:
First of all - functions must be exported using__declspec(dllexport / dllimport)
(more here - https://stackoverflow.com/questions/7671856/qlibrary-resolve-returns-false).
The second thing is that I cannot use the QTimer without a QThread.
To summarize - I have and app built with static msvc 5.15.2 and a Qt dll lib built with the same kit.The Dll project uses QTimer which is not working as it does being built with mingw kit (both dll and exe) due to lack of QThread in dll (as it says).
What I have figured out is - I have to run a different QCoreApplication within the dll so it has it's own QEventLoop which eventually leads to QTimer working. The problem is that I have to launch the dll init func only AFTER the main project QCoreApplication has "exacted" making the main program able to work. If it is done in this way - I am able to use QTimer within the lib as I want and the main thread is not "freezed".
I was able do it using QTimer::singleshot for 1sec. Pity but I am restricted of using another instance of QCoreApp in the dll lib so...
I will see if I am able to run QTimer in dll any other way.