| Summary: | Can not build Qt code with mingw32 gcc that uses dynamic_cast | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Fedora] Fedora | Reporter: | Mark <jedimark64> | ||||
| Component: | mingw32-qt | Assignee: | Thomas Sailer <fedora> | ||||
| Status: | CLOSED NOTABUG | QA Contact: | Fedora Extras Quality Assurance <extras-qa> | ||||
| Severity: | unspecified | Docs Contact: | |||||
| Priority: | unspecified | ||||||
| Version: | 15 | CC: | drizt72, erik-fedora, fedora, kalevlember, rjones | ||||
| Target Milestone: | --- | ||||||
| Target Release: | --- | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Whiteboard: | |||||||
| Fixed In Version: | Doc Type: | Bug Fix | |||||
| Doc Text: | Story Points: | --- | |||||
| Clone Of: | Environment: | ||||||
| Last Closed: | 2011-07-23 07:29:50 UTC | Type: | Bug | ||||
| Regression: | --- | Mount Type: | --- | ||||
| Documentation: | --- | CRM: | |||||
| Verified Versions: | Category: | --- | |||||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||
| Attachments: |
|
||||||
|
Description
Mark
2011-07-22 18:55:54 UTC
There's nothing within mingw32-qt that defines QT_NO_DYNAMIC_CAST - so it's either a problem within your project or the bug is assigned to the wrong package. We really need a small simple testcase for this. I looked into the bug a bit and QT_NO_DYNAMIC_CAST is apparently coming from qmake.
Reproducer:
[kalev@beagle tmp]$ mkdir /tmp/qmake-test
[kalev@beagle tmp]$ cd /tmp/qmake-test
[kalev@beagle qmake-test]$ cat > test.pro << EOF
> TEMPLATE = app
> SOURCES = test.cpp
> EOF
[kalev@beagle qmake-test]$ touch test.cpp
[kalev@beagle qmake-test]$ mingw32-qmake-qt4
[kalev@beagle qmake-test]$ make
make -f Makefile.Release
make[1]: Entering directory `/tmp/qmake-test'
i686-pc-mingw32-g++ -c -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 --param=ssp-buffer-size=4 -mms-bitfields -O2 -fexceptions -mthreads -Wall -fno-rtti -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NO_DYNAMIC_CAST -I'/usr/i686-pc-mingw32/sys-root/mingw/include/QtCore' -I'/usr/i686-pc-mingw32/sys-root/mingw/include/QtGui' -I'/usr/i686-pc-mingw32/sys-root/mingw/include' -I'/usr/i686-pc-mingw32/sys-root/mingw/include/ActiveQt' -I'release' -I'/usr/lib64/qt4/mkspecs/win32-g++-cross' -o release/test.o test.cpp
... and there's the -DQT_NO_DYNAMIC_CAST along with -fno-rtti.
As much as I can tell, qmake somehow includes /usr/lib64/qt4/mkspecs/features/win32/default_pre.prf and that in turn has CONFIG = rtti_off.
The tricky part is that .../win32/default_pre.prf is part of the native qmake install. I wonder if win32/default_pre.prf produced by the mingw32 crossbuild is any different, and what other differences might be in qmake configurations.
add CONFIG+=rtti to test.pro See: file:///usr/share/doc/qt4/html/qmake-variable-reference.html#config Created attachment 514807 [details]
Test case to demonstrate dynamic_cast
mingw32-qmake-qt4
make
i686-pc-mingw32-g++ -c -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 --param=ssp-buffer-size=4 -mms-bitfields -O2 -fexceptions -mthreads -Wall -fno-rtti -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NO_DYNAMIC_CAST -I'/usr/i686-pc-mingw32/sys-root/mingw/include/QtCore' -I'/usr/i686-pc-mingw32/sys-root/mingw/include' -I'/usr/i686-pc-mingw32/sys-root/mingw/include/ActiveQt' -I'release' -I'/usr/lib/qt4/mkspecs/win32-g++-cross' -o release/main.o main.cpp
main.cpp: In function 'int main(int, char**)':
main.cpp:36:11: warning: unused variable 'c'
main.cpp:39:11: warning: unused variable 'd'
In file included from /usr/i686-pc-mingw32/sys-root/mingw/include/QtCore/qalgorithms.h:45:0,
from /usr/i686-pc-mingw32/sys-root/mingw/include/QtCore/qdebug.h:45,
from /usr/i686-pc-mingw32/sys-root/mingw/include/QtCore/QDebug:1,
from main.cpp:8:
/usr/i686-pc-mingw32/sys-root/mingw/include/QtCore/qglobal.h: In function 'T qt_dynamic_cast_check(X, T*) [with T = bar*, X = foo*]':
main.cpp:36:34: instantiated from here
/usr/i686-pc-mingw32/sys-root/mingw/include/QtCore/qglobal.h:2388:15: error: 'dynamic_cast_will_always_fail_because_rtti_is_disabled' is not a member of 'bar*'
/usr/i686-pc-mingw32/sys-root/mingw/include/QtCore/qglobal.h: In function 'T qt_dynamic_cast_check(X, T*) [with T = baz*, X = foo*]':
main.cpp:39:34: instantiated from here
/usr/i686-pc-mingw32/sys-root/mingw/include/QtCore/qglobal.h:2388:15: error: 'dynamic_cast_will_always_fail_because_rtti_is_disabled' is not a member of 'baz*'
make[1]: *** [release/main.o] Error 1
make[1]: Leaving directory `/home/mark/test725079'
make: *** [release] Error 2
Thomas Sailer wrote "add CONFIG+=rtti to test.pro" This works.. Thankyou! But should it work differently to every other Qt install? Our behaviour seems to be consistent with the downloads from Nokia: http://developer.qt.nokia.com/forums/viewthread/4359 http://developer.qt.nokia.com/forums/viewthread/2802 It's debatable whether the default of rtti off (and only on windows, apparently) makes sense in this day and age. But you'd have to convince Nokia to change this. Some people claim that rtti on windows is problematic, but I don't know why. And qt has its own rtti system using qobject_cast. I'm closing this now. I have absolutely no problem with this, as it doesn't require a Qt rebuild. At least this is here closed in case anyone else comes across it.. |