Crash in custom widget example
-
I built customwidgetplugin using Qt Creator.
I created a minimum Qt Application (testwidget.vcproj) in VS2008 using the VS2008 add-in.
I opened testwidget.ui in Qt Designer and added the Widget, - object name is analogClock.
Back to VS2008.
- I copy analogclock.h into the project directory.
- I copy customwidgetplugin dll, lib and pdb into .\Debug directory.
The project builds with no errors or warnings.
I launch testwidget.exe and it finds and loads the plug-in.
But then it crashes at the constructor.void setupUi(QMainWindow *testwidgetClass) { if (testwidgetClass->objectName().isEmpty()) testwidgetClass->setObjectName(QString::fromUtf8("testwidgetClass")); testwidgetClass->resize(450, 316); centralWidget = new QWidget(testwidgetClass); centralWidget->setObjectName(QString::fromUtf8("centralWidget")); analogClock = new AnalogClock(centralWidget);
I have not modified or added a single line of code, but clearly I am misusing the tools in some way.
Here is the VS2008 output
'testwidget.exe': Loaded 'D:\Smartience2AV\MeeGo\testwidget\Debug\testwidget.exe', Symbols loaded.
'testwidget.exe': Loaded 'C:\Windows\System32\ntdll.dll'
'testwidget.exe': Loaded 'C:\Windows\System32\kernel32.dll'
'testwidget.exe': Loaded 'D:\NokiaQt\Qt4.7.1\bin\QtCored4.dll', Symbols loaded.
'testwidget.exe': Loaded 'C:\Windows\System32\user32.dll'
'testwidget.exe': Loaded 'C:\Windows\System32\gdi32.dll'
'testwidget.exe': Loaded 'C:\Windows\System32\advapi32.dll'
'testwidget.exe': Loaded 'C:\Windows\System32\rpcrt4.dll'
'testwidget.exe': Loaded 'C:\Windows\System32\ole32.dll'
'testwidget.exe': Loaded 'C:\Windows\System32\msvcrt.dll'
'testwidget.exe': Loaded 'C:\Windows\System32\ws2_32.dll'
'testwidget.exe': Loaded 'C:\Windows\System32\nsi.dll'
'testwidget.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_2a4cbfc25558bcd3\msvcp90d.dll', Symbols loaded.
'testwidget.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_2a4cbfc25558bcd3\msvcr90d.dll', Symbols loaded.
'testwidget.exe': Loaded 'D:\NokiaQt\Qt4.7.1\bin\QtGuid4.dll', Symbols loaded.
'testwidget.exe': Loaded 'C:\Windows\System32\comdlg32.dll'
'testwidget.exe': Loaded 'C:\Windows\System32\shlwapi.dll'
'testwidget.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.6001.18523_none_886c608850a2f36f\comctl32.dll'
'testwidget.exe': Loaded 'C:\Windows\System32\shell32.dll'
'testwidget.exe': Loaded 'C:\Windows\System32\oleaut32.dll'
'testwidget.exe': Loaded 'C:\Windows\System32\imm32.dll'
'testwidget.exe': Loaded 'C:\Windows\System32\msctf.dll'
'testwidget.exe': Loaded 'C:\Windows\System32\winmm.dll'
'testwidget.exe': Loaded 'C:\Windows\System32\oleacc.dll'
'testwidget.exe': Loaded 'C:\Windows\System32\winspool.drv'
'testwidget.exe': Loaded 'D:\Smartience2AV\MeeGo\testwidget\Debug\customwidgetplugin.dll', Binary was not built with debug information.
'testwidget.exe': Loaded 'D:\NokiaQt\Qt4.7.1\bin\QtGui4.dll', Binary was not built with debug information.
'testwidget.exe': Loaded 'D:\NokiaQt\Qt4.7.1\bin\QtCore4.dll', Binary was not built with debug information.
'testwidget.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_5090ab56bcba71c2\msvcp90.dll', Symbols loaded.
'testwidget.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_5090ab56bcba71c2\msvcr90.dll', Symbols loaded.
'testwidget.exe': Loaded 'C:\Windows\System32\lpk.dll'
'testwidget.exe': Loaded 'C:\Windows\System32\usp10.dll'
'testwidget.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.6001.18523_none_5cdd65e20837faf2\comctl32.dll'
'testwidget.exe': Loaded 'C:\Windows\System32\uxtheme.dll'
'testwidget.exe': Loaded 'C:\Program Files\SetPoint\lgscroll.dll', Binary was not built with debug information.
'testwidget.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.4053_none_d08d7da0442a985d\msvcr80.dll'
'testwidget.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.4053_none_d08d7da0442a985d\msvcp80.dll'
'testwidget.exe': Loaded 'C:\Windows\System32\ntmarta.dll'
'testwidget.exe': Loaded 'C:\Windows\System32\Wldap32.dll'
'testwidget.exe': Loaded 'C:\Windows\System32\psapi.dll'
'testwidget.exe': Loaded 'C:\Windows\System32\samlib.dll'
The program '[7424] testwidget.exe: Native' has exited with code 1 (0x1).Everything looks good until it dies in the constructor. Dependency Walker shows the entry point is there...
-
Yes, they are. And as the entry point is visible with Dependency Walker, it would appear that everything built correctly.
The problem is that I cannot debug into the DLL because it was not built in VS2008. Can anyone recommend a way forward (or make a divine guess as to the cause of the problem in the first place!)
-
[quote author="zing0000" date="1290662221"]The problem is that I cannot debug into the DLL because it was not built in VS2008. Can anyone recommend a way forward (or make a divine guess as to the cause of the problem in the first place!)
[/quote]You cannot mix C++ libs compiled with different versions of Visual Studio. All C++ code must be compiled with VS2008, including the Qt libs (there are prebuild binaries on the "downloads page":http://qt.nokia.com/downloads).
-
-
Success!
In Qt Creator, Projects tab, Build settings - I was correctly using the Microsoft Visual C++ tool chain BUT I had not selected the Release build.
The docs clearly state you must use a release build in VS2008.
Now it works, and I can debug into the DLL from VS2008.