PDA

View Full Version : Error when executing Qt application on Win7: possible issue with libstdc++-6.dll?



sol_kanar
1st December 2013, 20:36
I have a Qt project that is working well under Linux, and I am trying to run it under Windows 7 64 bit. I am using Qt 5.1.1 and mingw 4.8.

In order to create the executable starting from the .pro file, I followed the subsequent steps:
- run qmake.exe from directory Qt/5.1.1/mingw48_32/bin
- run mingw32-make.exe from directory Qt/Tools/mingw48_32/bin
- put all needed .dlls inside the folder with the freshly created .exe of my application. I took the .dlls from Qt/5.1.1/mingw48_32/bin. The libraries are:
-- icudt51.dll
-- icuin51.dll
-- icuuc51.dll
-- libstdc++-6.dll
-- libwinpthread-1.dll
-- Qt5Core.dll
-- Qt5Gui.dll
-- Qt5QWidgets.dll

When I try to run my application, it crashes immediately with the following error:

Problem signature:
Problem Event Name: APPCRASH
Application Name: ugp3-population-inspector.exe
Application Version: 0.0.0.0
Application Timestamp: 529b97e7
Fault Module Name: libstdc++-6.dll
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 516ee7b6
Exception Code: c0000005
Exception Offset: 00043f17
OS Version: 6.1.7601.2.1.0.768.3
Locale ID: 1036
Additional Information 1: 3a5f
Additional Information 2: 3a5f3876e9d420f8f9257cedd5068646
Additional Information 3: 58bf
Additional Information 4: 58bfe2891c811f25e4b9e96b50dd180b


So, it looks like there is some trouble with libstdc++-6.dll...but I don't really understand the issue.

Can anyone help me? Thanks in advance :-)

ChrisW67
1st December 2013, 21:35
Exception Code: c0000005

Is "Access violation" as a quick Google search will tell you. The code is almost certainly accessing a zero, uninitialised, or already freed pointer.

You also need to complete the deployment with the MingW runtime library (MINGWM10.DLL), "platforms/qwindows.dll" plugin for Windows, and the ANGLE related dlls (3 of them I think). Do that first as you will not get much further without them.
http://qt-project.org/doc/qt-5.0/qtdoc/deployment-windows.html#creating-the-application-package

sol_kanar
2nd December 2013, 11:15
Thanks for your help!

I've added all the .dlls, but I am still getting the same error.

I tried to proceed in a different way: I loaded my .pro in Qt Creator, I cleaned/re-built it and I tried to run it from there...but again, I got the same error.

EDIT: As a comparison, I also tried to run some programs from the "examples" folder in Qt/5.1.1, and Qt Creator was able to load, compile and execute them correctly.

What could be the issue?

stampede
2nd December 2013, 12:02
As a comparison, I also tried to run some programs from the "examples" folder in Qt/5.1.1, and Qt Creator was able to load, compile and execute them correctly.
Yes, because these programs do not have any "Access violation" bugs. Run debug version of your project under debugger and post stack trace after the crash.

sol_kanar
2nd December 2013, 14:03
Ok, I ran the Qt Center debugger, and here is what I got (see attached screenshot)

"Level 0" in the window is libstdc++-6.dll inside the folder where the executable is.

9828

stampede
2nd December 2013, 14:29
Can you post the content of main.cpp ? Line no. 12 in particular :)

sol_kanar
2nd December 2013, 16:15
#include "ui_ugp3-population-inspector.h"
#include "MicroGPMainWindow.h"
#include "MicroGPApplication.h"

using namespace std;
using namespace Ui;

// main
int main(int argc, char* argv[])
{
// create application
MicroGPApplication app(argc, argv);
// create widget that will be used as anchor for the ugp3.ui interface
QMainWindow* mainWindow = new QMainWindow;
// create window class defined by the ugp3.ui file
MicroGPMainWindow ugp3Window;

// bind window to widget
ugp3Window.setupUi(mainWindow);

// show window
mainWindow->show();

// return exit value of the application
return app.exec();
}

Here it is! Apparently, the program crashes when it tries to create a MicroGPApplication object (which is a class inherited from QApplication). Here is the code for the MicroGPApplication class (it's just a header file):


#ifndef MICROGPAPPLICATION
#define MICROGPAPPLICATION

#include <QtGui>
#include <QApplication>
#include <QMessageBox>

class MicroGPApplication : public QApplication
{
public:
MicroGPApplication(int& argc, char ** argv) : QApplication(argc, argv) { }
virtual ~MicroGPApplication() { }

// reimplemented from QApplication so we can throw exceptions in slots
virtual bool notify(QObject * receiver, QEvent * event)
{
try
{
return QApplication::notify(receiver, event);
}
catch(std::exception& e)
{
QMessageBox::warning( 0, tr("An error occurred"), e.what() );
}

return false;
}
};

#endif

Added after 22 minutes:

Just a quick update: I finally managed to solve the issue. I have another system with Win7 64-bit, I just installed Qt 5.1.1 along with mingw 4.8, and - after a minor tweaking with the .pro - Qt Creator was able to successfully build and run the program.

On the other system, I had a separate, different version of mingw already installed when I installed Qt 5.1.1; so, my guess is that there was some kind of issue between the two versions (and probably the folders of *both* were inside PATH).

Thanks everyone for your help! :-)