Answer the question
In order to leave comments, you need to log in
Qt program crashes when using DLL function multiple times
I create a clean project in Qt Creator. In the form constructor, I include the DLL and try to reuse the function from the DLL:
MainWindow :: MainWindow ( QWidget * parent )  :
    QMainWindow ( parent ) ,
    ui ( new  Ui :: MainWindow )
{
    ui - > setupUi ( this ) ;
Â
    QLibrary * library =  new  QLibrary ( "UniversalDLL.dll" ) ;
Â
    typedef  int  ( * testFunc ) ( int ) ;
    testFunc tst =  ( testFunc )  library - > resolve ( "wrr" ) ;
    if  ( ! tst )
    {
        QMessageBox :: critical ( this , this - > windowTitle ( ) , tr ( "Error loading DLL!" ) ) ;
        exit ( 0 ) ;
    }
Â
    qDebug ( )  <<  tst ( 1 ) ;
    qDebug ( )  <<  tst ( 2 ) ;
    qDebug ( )  <<  tst ( 3 ) ;
    qDebug ( )  <<  tst ( 4 ) ;
    qDebug ( )  <<  tst ( 5 ) ;
    qDebug ( )  <<  tst ( 6 ) ;
    qDebug ( )  <<  tst ( 7 ) ;
    qDebug ( )  <<  tst ( 8 ) ;
    qDebug ( )  <<  tst ( 9 ) ;
    qDebug ( )  <<  tst ( 10 ) ;
    qDebug ( )  <<  tst ( 11 ) ;
    qDebug ( )  <<  tst ( 12 ) ;
    qDebug ( )  <<  tst ( 13 ) ;
    qDebug ( )  <<  tst ( 14 ) ;
    qDebug ( )  <<  tst ( 15 ) ;
}
extern  "C"  __declspec ( dllexport )  int  __stdcall wrr ( int  abonent )
{
return  abonent ;
}
Answer the question
In order to leave comments, you need to log in
I can advise you to make a function without the __stdcall modifier and try to build Qt in Debug, and then pick up the raw Qt and see where the error occurs.
However, this error looks more like an Access violation or Stack overflow. I advise you to test the code on other machines with windows. If the problem persists, it may be a stack overload, which, by the way, is not surprising, because __stdcall means that arguments are passed through the stack.
Alas, I cannot comment on this error and behavior in the Windows environment in any way, but I advise you to analyze it without such a modifier, or replacing it with some other one.
as I understood dll and the project itself are assembled by different compilers? Maybe it's in __stdcall then?
Thank you all for your answers, tomorrow at work I'll try to remove __stdcall.
Thanks, you were all right. Removed __stdcall and everything worked like clockwork. Only the reason is not very clear, because. not yet familiar with the stack. I will read and devote myself, I will also be grateful for links where this is explained in an accessible way.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question