Cannot use typeid with -fno-rtti [SOLVED]
-
wrote on 24 Oct 2012, 16:11 last edited by
Hi folks,
I'm using mingw4.0.4 with QT4.8.3 and Creator 2.5.2.
I just want to compile the following simple line of code in a default hello world console program:@cout<<typeid(a).name()<<endl;@
The compiler brings the following error:
'cannot use typeid with -fno-rtti'
Any idea how to fix this? Where can i add/remove such compiler parameters? I only found the qmake arguments!
Big thanks in advance.
-
wrote on 24 Oct 2012, 22:15 last edited by
typeid is only available with runtime type information (rtti).
AFAIK, Qt by default is compiled without rtti. You can add compile parameters in the qmake file so your code has rtti but then take care to not try it on Qt classes. -
wrote on 25 Oct 2012, 10:03 last edited by
What exact parameter do I have to add to have rtti?
OK - I found it in the build directory: Makefile.XXX CXXFLAGSCXXFLAGS = -O2 -Wall -Wextra -fno-exceptions -fno-rtti $(DEFINES)
The Problem is, that when I rebuild or clean the projects, these makefiles will be recreated with -fno-rtti!!! Grrrrr
Isn't it somehow possible to set this up in the project itself? When I just check in the .pro files and the source files! So everybody who is working on the projects has to change it himself? There must be a more common way?!? -
wrote on 25 Oct 2012, 10:42 last edited by
I only include this, and works:
#include <typeinfo> -
wrote on 25 Oct 2012, 11:51 last edited by
[quote author="broadpeak" date="1351161772"]I only include this, and works:
#include <typeinfo>[/quote]With MinGW under Windows? Im working on the same projects under Ubuntu using gcc with no problem, too.
-
wrote on 25 Oct 2012, 12:19 last edited by
I used it under Windows but with MinGW. (QtSDK 1.2.1)
-
wrote on 26 Oct 2012, 07:35 last edited by
[quote author="broadpeak" date="1351167587"]I used it under Windows but with MinGW. (QtSDK 1.2.1)[/quote]
Hmm... That is a very old version don't u think!?
Anyways, it's not working by default on any of my workstations using MinGW!
So my question still is: Is it somehow possible to set CXXFLAGS via .pro file or creator settings?
I don't want all developers to change their global configs just to compile this project!
hmm....Thanks in advice
-
wrote on 26 Oct 2012, 07:52 last edited by
My Qt is:
g++ = 4.4.0
qt = 4.8.1
I think these are not so old versions...
And in my .pro file there is nothing about the RTTI.
I only use the above mentioned include file. -
wrote on 26 Oct 2012, 13:30 last edited by
Hahaha :)
I run into the same issue :)Solution:
in .pro file:
CONFIG += rtti (this is enough in theory)
or
CXXFLAGS = -g -Wall -Wextra -fno-exceptions -fno-rtti $(DEFINES) -
wrote on 26 Oct 2012, 14:24 last edited by
Thanks I'll give it a try!
-
wrote on 8 Nov 2012, 17:12 last edited by
Hey fellas,
Sorry i forgot to post my result here:
The following solved the problem (like broadpeak said! Thank you!)
In the .pro file just add the line
@CONFIG += rtti@That's it.
See u guys around