Create a blank project in Qt Creator. In the form constructor, connect the DLL and trying to reuse a 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() << the tst(8);
qDebug() << the tst(9);
qDebug() << tst(10);
qDebug() << tst(11);
qDebug() << tst(12);
qDebug() << tst(13);
qDebug() << tst(14);
qDebug() << tst(15);
}
DLLка is in the folder with the project and successfully connects, it is only one function (the DLL project is created in Visual Studio):
extern "C" __declspec(dllexport) int __stdcall wrr(int abonent)
{
return abonent;
}
The crash happens both in release and in debug, and the number of usages of the function before the crash programs are different in debug and relese:
C:\\testettstettd\elease\\testettstettd.exe exited with code -1073741819
For example, now, in release smash 7 iteration use functions from a DLL, and in debug (just weird?!) stopped breaking.
Single use functions from the DLL works. What the hell, the third day went on, trying to understand. Tried to connect without using QLibrary and dynamically and statically. The problem is most likely not the DLL, because it never turns on dllcache and DLL from a project in Delphi successfully connects and works. Well, as usual: PAMAGITE!?