ModelViewVTK produce a crash on Windows when app is compiled in debug
A Qt App using ModelViewVTK
produces a crash on Windows when compiled in debug mode. The application terminate with the following error message:
QWidget: Must construct a QApplication before a QWidget
The problem seems to be a mismatch between debug and release versions of the DLL. The main app loads Qt5Cored.dll
on start, but libvtkGUISupportQt-7.1.dll
loads Qt5Core.dll
, because VTK itself is built and installed in release mode. This is a standard MSYS2 setup with VTK 7.1.1 and Qt 5.9.1.
It is somewhat related to Shared builds of VTK and debugging QVTKWidget using Visual Studio, but here the goal is to debug the main app, not VTK itself.
One workaround would be to always use the release lib Qt5Core.dll
. However, CMake is clever and imports the Qt library build corresponding to CMAKE_BUILD_TYPE
. What would be the proper way of fixing this issue? Thanks!