Failure to find OpenGL and weird warnings in MSVC 2019
-
Hello all,
I'm getting some weird errors when using MSVC 2019 to compile and run QT. Namely, the following:
Severity Code Description Project File Line Suppression State Warning C26451 Arithmetic overflow: Using operator '+' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '+' to avoid overflow (io.2). project_name c:\qt\5.12.2\msvc2017\include\qtcore\qglobal.h 591 Warning C26451 Arithmetic overflow: Using operator '-' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '-' to avoid overflow (io.2). project_name c:\qt\5.12.2\msvc2017\include\qtcore\qglobal.h 591 Warning C26451 Arithmetic overflow: Using operator '+' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '+' to avoid overflow (io.2). project_name c:\qt\5.12.2\msvc2017\include\qtcore\qglobal.h 591 Warning C26451 Arithmetic overflow: Using operator '-' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '-' to avoid overflow (io.2). project_name c:\qt\5.12.2\msvc2017\include\qtcore\qglobal.h 591 Warning C26498 The function 'qMetaTypeId<QtMetaTypePrivate::QPairVariantInterfaceImpl>' is constexpr, mark variable 'toId' constexpr if compile-time evaluation is desired (con.5). project_name c:\qt\5.12.2\msvc2017\include\qtcore\qmetatype.h 2287 Warning C26495 Variable 'QtSharedPointer::ExternalRefCountData::destroyer' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtcore\qsharedpointer_impl.h 154 Warning C26495 Variable 'QtSharedPointer::ExternalRefCountData::strongref' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtcore\qsharedpointer_impl.h 154 Warning C26495 Variable 'QtSharedPointer::ExternalRefCountData::weakref' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtcore\qsharedpointer_impl.h 154 Warning C26495 Variable 'QStringView::m_data' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtcore\qstringview.h 207 Warning C26495 Variable 'QStringView::m_size' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtcore\qstringview.h 207 Warning C26498 The function 'qMetaTypeId<QHash<QString,QVariant> >' is constexpr, mark variable 'vid' constexpr if compile-time evaluation is desired (con.5). project_name c:\qt\5.12.2\msvc2017\include\qtcore\qvariant.h 721 Warning C26498 The function 'qMetaTypeId<QList<QVariant> >' is constexpr, mark variable 'vid' constexpr if compile-time evaluation is desired (con.5). project_name c:\qt\5.12.2\msvc2017\include\qtcore\qvariant.h 721 Warning C26498 The function 'qMetaTypeId<QMap<QString,QVariant> >' is constexpr, mark variable 'vid' constexpr if compile-time evaluation is desired (con.5). project_name c:\qt\5.12.2\msvc2017\include\qtcore\qvariant.h 721 Warning C26498 The function 'qMetaTypeId<QPair<QVariant,QVariant> >' is constexpr, mark variable 'vid' constexpr if compile-time evaluation is desired (con.5). project_name c:\qt\5.12.2\msvc2017\include\qtcore\qvariant.h 721 Warning C26498 The function 'qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>' is constexpr, mark variable 'vid' constexpr if compile-time evaluation is desired (con.5). project_name c:\qt\5.12.2\msvc2017\include\qtcore\qvariant.h 721 Warning C26498 The function 'qMetaTypeId<QtMetaTypePrivate::QPairVariantInterfaceImpl>' is constexpr, mark variable 'vid' constexpr if compile-time evaluation is desired (con.5). project_name c:\qt\5.12.2\msvc2017\include\qtcore\qvariant.h 721 Warning C26498 The function 'qMetaTypeId<QtMetaTypePrivate::QSequentialIterableImpl>' is constexpr, mark variable 'vid' constexpr if compile-time evaluation is desired (con.5). project_name c:\qt\5.12.2\msvc2017\include\qtcore\qvariant.h 721 Warning C26495 Variable 'QColor::cspec' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtgui\qcolor.h 283 Warning C26495 Variable 'QColor::ct' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtgui\qcolor.h 283 Warning C26495 Variable 'QColor::cspec' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtgui\qcolor.h 286 Warning C26495 Variable 'QColor::ct' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtgui\qcolor.h 286 Warning C26495 Variable 'QColor::cspec' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtgui\qcolor.h 289 Warning C26495 Variable 'QColor::ct' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtgui\qcolor.h 289 Warning C26495 Variable 'QColor::cspec' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtgui\qcolor.h 292 Warning C26495 Variable 'QColor::ct' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtgui\qcolor.h 292 Warning C26495 Variable 'QColor::cspec' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtgui\qcolor.h 296 Warning C26495 Variable 'QColor::ct' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtgui\qcolor.h 296 Warning C26439 This kind of function may not throw. Declare it 'noexcept' (f.6). project_name c:\qt\5.12.2\msvc2017\include\qtgui\qfontmetrics.h 149 Warning C26495 Variable 'QMatrix::_dx' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtgui\qmatrix.h 60 Warning C26495 Variable 'QMatrix::_dy' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtgui\qmatrix.h 60 Warning C26495 Variable 'QMatrix::_m11' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtgui\qmatrix.h 60 Warning C26495 Variable 'QMatrix::_m12' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtgui\qmatrix.h 60 Warning C26495 Variable 'QMatrix::_m21' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtgui\qmatrix.h 60 Warning C26495 Variable 'QMatrix::_m22' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtgui\qmatrix.h 60 Warning C26495 Variable 'QMatrix::_dx' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtgui\qmatrix.h 70 Warning C26495 Variable 'QMatrix::_dy' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtgui\qmatrix.h 70 Warning C26495 Variable 'QMatrix::_m11' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtgui\qmatrix.h 70 Warning C26495 Variable 'QMatrix::_m12' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtgui\qmatrix.h 70 Warning C26495 Variable 'QMatrix::_m21' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtgui\qmatrix.h 70 Warning C26495 Variable 'QMatrix::_m22' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtgui\qmatrix.h 70 Warning C26495 Variable 'QPalette::<anonymous-tag>::for_faster_swapping_dont_use' is uninitialized. Always initialize a member variable (type.6). project_name c:\qt\5.12.2\msvc2017\include\qtgui\qpalette.h 71
So I wasn't too worried about these, but maybe I should be. I'm not even sure if they're related to my main problem, which is that visual studio isn't finding any versions of OpenGL. My only idea of a cause is that maybe the MSVC2017 build binaries aren't compatible with MSVC2019 like I initially hoped, but a google search tells me that I should be fine. When I try to create some #ifdefs, I always get the error that I'm throwing in the #else block of the following code:
QSurfaceFormat format; #if defined(QT_OPENGL_ES_3) format = settings->configOpenGLES(); // Configuring format for Open GL ES 3.0 #elif defined(QT_OPENGL_ES_2) throw("Error, Open GL ES 2.0 is not supported by this hardware"); #elif defined(QT_OPENGL) format = settings->configOpenGL(); #else throw("Error, no rendering modes supported by this hardware"); #endif
I'm not very familiar with Qt (and am developing on Windows), but I did notice that all versions of Open GL are disabled in my C:\Qt\5.12.2\msvc2017\include\QtGui\qtgui-config.h file. I'm not sure if this is related at all, since that file is just something that ships with Qt.
Lastly, my .pro looks like this:
message("Beginning qmake build of project_name.pro") TEMPLATE = app TARGET = project_name QT += core \ opengl \ gui \ widgets \ concurrent \ # Mutexes/multithreading openglextensions \ network # TCP/IP # Set general configuration options ///////////////////////////////////////////////// CONFIG += c++latest # Add support for c++17. CONFIG += qt thread # console CONFIG += debug_and_release # Creates additional debug and release folders, but need it for debug CONFIG(debug, debug|release){ DESTDIR = ../app/debug } else { DESTDIR = ../app/release } CONFIG += no_lflags_merge # Ensures that the list of libraries stored in the LIBS variable is not reduced to a list of unique values before it is used. # CONFIG += CONSOLE # makes this a console application CONFIG += flat # flattens file hierarchy, subtract if this is not desired # Do not display debug output in release mode CONFIG(debug, debug|release) : CONFIG += debug_info CONFIG(release, debug|release) : DEFINES += QT_NO_DEBUG_OUTPUT # Defines ////////////////////////////////////////////////////////////////////////// DEFINES += _UNICODE _ENABLE_EXTENDED_ALIGNED_STORAGE WIN64 QT_DLL QT_OPENGL_LIB QT_OPENGLEXTENSIONS_LIB QT_WIDGETS_LIB INCLUDEPATH += ./qt_generated \ . \ ./qt_generated/$(ConfigurationName) LIBS += -lopengl32 \ -lglu32 DEPENDPATH += . # Set directories ////////////////////////////////////////////////////////////////// MOC_DIR += ./qt_generated/moc OBJECTS_DIR += ./qt_generated/obj UI_DIR += ./qt_generated/ui RCC_DIR += ./qt_generated message("Loaded .pro files, now loading .pri") # Load in library files for project include(project_name.pri) message("Loaded .pri files")
Which I am running with the following .bat file:
REM Build main app with visual studio make and qmake call C:\"Program Files (x86)"\"Microsoft Visual Studio"\2019\Community\VC\Auxiliary\Build\vcvarsall.bat x86 && cd C:\Users\me\Documents\Projects\project-dir\project_name && call c:\Qt\5.12.2\msvc2017\bin\qmake -r -tp vc || echo qmake failed, Exit Code is %errorlevel% )
Any suggestions?
Edit: Just tried this with MSVC 2017. I'm no longer getting the warnings that I was getting before. However, my check for the QT_OPENGL macro variants is still not working. Any ideas? Is it possible that my system simply does not support open GL ES? If this is the case, how do I develop to support open GL ES?
-
@feistykittykat Don't know if I'm allowed to bump this bad boy up. Been struggling to use PVRVFrame or something similar to get openGL found on my machine, but I have no idea how to set it up for QT. Still not even sure if that's the source of my problem.