Qt - unable to terminate console app after loading library <p>I have a problem with QT console application. At the beginning of my code in main, i load a dll using QLibrary. When i exit the app by returning 0 if the mode i checked from my dll is incorrect, the app will crash; stating "QObject:: shared object was deleted directly. The program is malformed and may crash.". Can anyone help me in this? </p> <p>Here's my code</p> <pre><code>int mode = -1; QLibrary myLib("checkmode.dll", 0); myLib.load(); if (myLib.isLoaded()) { typedef int (*GetModeStatusFunction)(char *, int, char *); GetModeStatusFunction GetModeStatus = (GetModeStatusFunction) myLib.resolve("GetModeStatus"); if (GetModeStatus) { mode = GetModeStatus("localhost", 10, NULL); } } if (mode!= 0) { return 0; // crash when return } </code></pre>