Debugging Exception -> Qt Creator + VTK + MSVC + QMake
-
Hi,
I have made a VTK+Qt build using QMake and Qt Creator. After days of trying I have successfully managed to run the SimpleView example (https://gitlab.kitware.com/vtk/vtk/-/tree/master/Examples/GUI/Qt/SimpleView) in both Debug and Release builds.
Here is my .pro file (sorry a bit long).
QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 # You can make your code fail to compile if it uses deprecated APIs. # In order to do so, uncomment the following line. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ main.cpp \ simpleview.cpp HEADERS += \ simpleview.h FORMS += \ simpleview.ui # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target INCLUDEPATH += C:\VTK\install\include\vtk-9.0\ LIBS += -LC:\vtk\install\lib\ CONFIG(release, debug|release) { #RELEASE LIBS message (Release Build Detected) LIBS += -lvtkChartsCore-9.0 LIBS += -lvtkCommonColor-9.0 LIBS += -lvtkCommonComputationalGeometry-9.0 LIBS += -lvtkCommonCore-9.0 LIBS += -lvtkCommonDataModel-9.0 LIBS += -lvtkCommonExecutionModel-9.0 LIBS += -lvtkCommonMath-9.0 LIBS += -lvtkCommonMisc-9.0 LIBS += -lvtkCommonSystem-9.0 LIBS += -lvtkCommonTransforms-9.0 LIBS += -lvtkDICOMParser-9.0 LIBS += -lvtkDomainsChemistry-9.0 LIBS += -lvtkDomainsChemistryOpenGL2-9.0 LIBS += -lvtkdoubleconversion-9.0 LIBS += -lvtkexodusII-9.0 LIBS += -lvtkexpat-9.0 LIBS += -lvtkFiltersAMR-9.0 LIBS += -lvtkFiltersCore-9.0 LIBS += -lvtkFiltersExtraction-9.0 LIBS += -lvtkFiltersFlowPaths-9.0 LIBS += -lvtkFiltersGeneral-9.0 LIBS += -lvtkFiltersGeneric-9.0 LIBS += -lvtkFiltersGeometry-9.0 LIBS += -lvtkFiltersHybrid-9.0 LIBS += -lvtkFiltersHyperTree-9.0 LIBS += -lvtkFiltersImaging-9.0 LIBS += -lvtkFiltersModeling-9.0 LIBS += -lvtkFiltersParallel-9.0 LIBS += -lvtkFiltersParallelImaging-9.0 LIBS += -lvtkFiltersPoints-9.0 LIBS += -lvtkFiltersProgrammable-9.0 LIBS += -lvtkFiltersSelection-9.0 LIBS += -lvtkFiltersSMP-9.0 LIBS += -lvtkFiltersSources-9.0 LIBS += -lvtkFiltersStatistics-9.0 LIBS += -lvtkFiltersTexture-9.0 LIBS += -lvtkFiltersTopology-9.0 LIBS += -lvtkFiltersVerdict-9.0 LIBS += -lvtkfreetype-9.0 LIBS += -lvtkGeovisCore-9.0 LIBS += -lvtkgl2ps-9.0 LIBS += -lvtkglew-9.0 LIBS += -lvtkGUISupportQt-9.0 LIBS += -lvtkGUISupportQtSQL-9.0 LIBS += -lvtkhdf5-9.0 LIBS += -lvtkhdf5_hl-9.0 LIBS += -lvtkImagingColor-9.0 LIBS += -lvtkImagingCore-9.0 LIBS += -lvtkImagingFourier-9.0 LIBS += -lvtkImagingGeneral-9.0 LIBS += -lvtkImagingHybrid-9.0 LIBS += -lvtkImagingMath-9.0 LIBS += -lvtkImagingMorphological-9.0 LIBS += -lvtkImagingSources-9.0 LIBS += -lvtkImagingStatistics-9.0 LIBS += -lvtkImagingStencil-9.0 LIBS += -lvtkInfovisCore-9.0 LIBS += -lvtkInfovisLayout-9.0 LIBS += -lvtkInteractionImage-9.0 LIBS += -lvtkInteractionStyle-9.0 LIBS += -lvtkInteractionWidgets-9.0 LIBS += -lvtkIOAMR-9.0 LIBS += -lvtkIOAsynchronous-9.0 LIBS += -lvtkIOCityGML-9.0 LIBS += -lvtkIOCore-9.0 LIBS += -lvtkIOEnSight-9.0 LIBS += -lvtkIOExodus-9.0 LIBS += -lvtkIOExport-9.0 LIBS += -lvtkIOExportGL2PS-9.0 LIBS += -lvtkIOExportPDF-9.0 LIBS += -lvtkIOGeometry-9.0 LIBS += -lvtkIOImage-9.0 LIBS += -lvtkIOImport-9.0 LIBS += -lvtkIOInfovis-9.0 LIBS += -lvtkIOLegacy-9.0 LIBS += -lvtkIOLSDyna-9.0 LIBS += -lvtkIOMINC-9.0 LIBS += -lvtkIOMotionFX-9.0 LIBS += -lvtkIOMovie-9.0 LIBS += -lvtkIONetCDF-9.0 LIBS += -lvtkIOOggTheora-9.0 LIBS += -lvtkIOParallel-9.0 LIBS += -lvtkIOParallelXML-9.0 LIBS += -lvtkIOPLY-9.0 LIBS += -lvtkIOSegY-9.0 LIBS += -lvtkIOSQL-9.0 LIBS += -lvtkIOTecplotTable-9.0 LIBS += -lvtkIOVeraOut-9.0 LIBS += -lvtkIOVideo-9.0 LIBS += -lvtkIOXML-9.0 LIBS += -lvtkIOXMLParser-9.0 LIBS += -lvtkjpeg-9.0 LIBS += -lvtkjsoncpp-9.0 LIBS += -lvtklibharu-9.0 LIBS += -lvtklibproj-9.0 LIBS += -lvtklibxml2-9.0 LIBS += -lvtkloguru-9.0 LIBS += -lvtklz4-9.0 LIBS += -lvtklzma-9.0 LIBS += -lvtkmetaio-9.0 LIBS += -lvtknetcdf-9.0 LIBS += -lvtkogg-9.0 LIBS += -lvtkParallelCore-9.0 LIBS += -lvtkParallelDIY-9.0 LIBS += -lvtkpng-9.0 LIBS += -lvtkpugixml-9.0 LIBS += -lvtkRenderingAnnotation-9.0 LIBS += -lvtkRenderingContext2D-9.0 LIBS += -lvtkRenderingContextOpenGL2-9.0 LIBS += -lvtkRenderingCore-9.0 LIBS += -lvtkRenderingFreeType-9.0 LIBS += -lvtkRenderingGL2PSOpenGL2-9.0 LIBS += -lvtkRenderingImage-9.0 LIBS += -lvtkRenderingLabel-9.0 LIBS += -lvtkRenderingLOD-9.0 LIBS += -lvtkRenderingOpenGL2-9.0 LIBS += -lvtkRenderingQt-9.0 LIBS += -lvtkRenderingSceneGraph-9.0 LIBS += -lvtkRenderingUI-9.0 LIBS += -lvtkRenderingVolume-9.0 LIBS += -lvtkRenderingVolumeOpenGL2-9.0 LIBS += -lvtkRenderingVtkJS-9.0 LIBS += -lvtksqlite-9.0 LIBS += -lvtksys-9.0 LIBS += -lvtkTestingRendering-9.0 LIBS += -lvtktheora-9.0 LIBS += -lvtktiff-9.0 LIBS += -lvtkverdict-9.0 LIBS += -lvtkViewsContext2D-9.0 LIBS += -lvtkViewsCore-9.0 LIBS += -lvtkViewsInfovis-9.0 LIBS += -lvtkViewsQt-9.0 LIBS += -lvtkWrappingTools-9.0 LIBS += -lvtkzlib-9.0 } CONFIG(debug, debug|release) { #DEBUG LIBS message (Debug Build Detected) LIBS += -lvtkChartsCore-9.0d LIBS += -lvtkCommonColor-9.0d LIBS += -lvtkCommonComputationalGeometry-9.0d LIBS += -lvtkCommonCore-9.0d LIBS += -lvtkCommonDataModel-9.0d LIBS += -lvtkCommonExecutionModel-9.0d LIBS += -lvtkCommonMath-9.0d LIBS += -lvtkCommonMisc-9.0d LIBS += -lvtkCommonSystem-9.0d LIBS += -lvtkCommonTransforms-9.0d LIBS += -lvtkDICOMParser-9.0d LIBS += -lvtkDomainsChemistry-9.0d LIBS += -lvtkDomainsChemistryOpenGL2-9.0d LIBS += -lvtkdoubleconversion-9.0d LIBS += -lvtkexodusII-9.0d LIBS += -lvtkexpat-9.0d LIBS += -lvtkFiltersAMR-9.0d LIBS += -lvtkFiltersCore-9.0d LIBS += -lvtkFiltersExtraction-9.0d LIBS += -lvtkFiltersFlowPaths-9.0d LIBS += -lvtkFiltersGeneral-9.0d LIBS += -lvtkFiltersGeneric-9.0d LIBS += -lvtkFiltersGeometry-9.0d LIBS += -lvtkFiltersHybrid-9.0d LIBS += -lvtkFiltersHyperTree-9.0d LIBS += -lvtkFiltersImaging-9.0d LIBS += -lvtkFiltersModeling-9.0d LIBS += -lvtkFiltersParallel-9.0d LIBS += -lvtkFiltersParallelImaging-9.0d LIBS += -lvtkFiltersPoints-9.0d LIBS += -lvtkFiltersProgrammable-9.0d LIBS += -lvtkFiltersSelection-9.0d LIBS += -lvtkFiltersSMP-9.0d LIBS += -lvtkFiltersSources-9.0d LIBS += -lvtkFiltersStatistics-9.0d LIBS += -lvtkFiltersTexture-9.0d LIBS += -lvtkFiltersTopology-9.0d LIBS += -lvtkFiltersVerdict-9.0d LIBS += -lvtkfreetype-9.0d LIBS += -lvtkGeovisCore-9.0d LIBS += -lvtkgl2ps-9.0d LIBS += -lvtkglew-9.0d LIBS += -lvtkGUISupportQt-9.0d LIBS += -lvtkGUISupportQtSQL-9.0d LIBS += -lvtkhdf5-9.0d LIBS += -lvtkhdf5_hl-9.0d LIBS += -lvtkImagingColor-9.0d LIBS += -lvtkImagingCore-9.0d LIBS += -lvtkImagingFourier-9.0d LIBS += -lvtkImagingGeneral-9.0d LIBS += -lvtkImagingHybrid-9.0d LIBS += -lvtkImagingMath-9.0d LIBS += -lvtkImagingMorphological-9.0d LIBS += -lvtkImagingSources-9.0d LIBS += -lvtkImagingStatistics-9.0d LIBS += -lvtkImagingStencil-9.0d LIBS += -lvtkInfovisCore-9.0d LIBS += -lvtkInfovisLayout-9.0d LIBS += -lvtkInteractionImage-9.0d LIBS += -lvtkInteractionStyle-9.0d LIBS += -lvtkInteractionWidgets-9.0d LIBS += -lvtkIOAMR-9.0d LIBS += -lvtkIOAsynchronous-9.0d LIBS += -lvtkIOCityGML-9.0d LIBS += -lvtkIOCore-9.0d LIBS += -lvtkIOEnSight-9.0d LIBS += -lvtkIOExodus-9.0d LIBS += -lvtkIOExport-9.0d LIBS += -lvtkIOExportGL2PS-9.0d LIBS += -lvtkIOExportPDF-9.0d LIBS += -lvtkIOGeometry-9.0d LIBS += -lvtkIOImage-9.0d LIBS += -lvtkIOImport-9.0d LIBS += -lvtkIOInfovis-9.0d LIBS += -lvtkIOLegacy-9.0d LIBS += -lvtkIOLSDyna-9.0d LIBS += -lvtkIOMINC-9.0d LIBS += -lvtkIOMotionFX-9.0d LIBS += -lvtkIOMovie-9.0d LIBS += -lvtkIONetCDF-9.0d LIBS += -lvtkIOOggTheora-9.0d LIBS += -lvtkIOParallel-9.0d LIBS += -lvtkIOParallelXML-9.0d LIBS += -lvtkIOPLY-9.0d LIBS += -lvtkIOSegY-9.0d LIBS += -lvtkIOSQL-9.0d LIBS += -lvtkIOTecplotTable-9.0d LIBS += -lvtkIOVeraOut-9.0d LIBS += -lvtkIOVideo-9.0d LIBS += -lvtkIOXML-9.0d LIBS += -lvtkIOXMLParser-9.0d LIBS += -lvtkjpeg-9.0d LIBS += -lvtkjsoncpp-9.0d LIBS += -lvtklibharu-9.0d LIBS += -lvtklibproj-9.0d LIBS += -lvtklibxml2-9.0d LIBS += -lvtkloguru-9.0d LIBS += -lvtklz4-9.0d LIBS += -lvtklzma-9.0d LIBS += -lvtkmetaio-9.0d LIBS += -lvtknetcdf-9.0d LIBS += -lvtkogg-9.0d LIBS += -lvtkParallelCore-9.0d LIBS += -lvtkParallelDIY-9.0d LIBS += -lvtkpng-9.0d LIBS += -lvtkpugixml-9.0d LIBS += -lvtkRenderingAnnotation-9.0d LIBS += -lvtkRenderingContext2D-9.0d LIBS += -lvtkRenderingContextOpenGL2-9.0d LIBS += -lvtkRenderingCore-9.0d LIBS += -lvtkRenderingFreeType-9.0d LIBS += -lvtkRenderingGL2PSOpenGL2-9.0d LIBS += -lvtkRenderingImage-9.0d LIBS += -lvtkRenderingLabel-9.0d LIBS += -lvtkRenderingLOD-9.0d LIBS += -lvtkRenderingOpenGL2-9.0d LIBS += -lvtkRenderingQt-9.0d LIBS += -lvtkRenderingSceneGraph-9.0d LIBS += -lvtkRenderingUI-9.0d LIBS += -lvtkRenderingVolume-9.0d LIBS += -lvtkRenderingVolumeOpenGL2-9.0d LIBS += -lvtkRenderingVtkJS-9.0d LIBS += -lvtksqlite-9.0d LIBS += -lvtksys-9.0d LIBS += -lvtkTestingRendering-9.0d LIBS += -lvtktheora-9.0d LIBS += -lvtktiff-9.0d LIBS += -lvtkverdict-9.0d LIBS += -lvtkViewsContext2D-9.0d LIBS += -lvtkViewsCore-9.0d LIBS += -lvtkViewsInfovis-9.0d LIBS += -lvtkViewsQt-9.0d LIBS += -lvtkWrappingTools-9.0d LIBS += -lvtkzlib-9.0d } # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target RESOURCES += \ Icons/icons.qrc
As you can see the only way I could find to get it to work for both debug and release builds was to use CONIFG (debug, debug|release) and CONFIG (release, debug|release) to conditionally link to the release or debug libraries, and NOT both.
Is this the right way to do this?
Is there a simpler way rather than listing out all the libs?
Is this fix a symptom of a bigger issue?NOTE: I have built VTK in both release and debug.
Thank you,
Ahmed
-
https://doc.qt.io/archives/qt-4.8/qmake-variable-reference.html
something like the following?
build_pass:CONFIG(debug) {
unix: LIBS += -Lvtk_debug_path
}
build_pass:CONFIG(release) {
unix: LIBS += -Lvtk_release_path
}the lib names may not change.
LIBS += -lvtk1 -lvtk2 .... -
Thanks. Do you know if there is an alternative to listing out all the libraries?
-
@AhmedAlshawi I would prefer to add the ones needed. Try to make your app as small as possible.
-
The simplest way is to use CMake to configure your project instead of a .pro file and qmake. That example even includes a CMakeLists.txt file for you to use. QtCreator supports CMake-based projects and Qt has switched to using it as its primary build system for developing Qt.