Building Qt 4.8.7 using g++ 6.3.0 with -std=gnu++98 on Debian 9.2.1 "stretch"
-
We are currently still using Qt 4.8.7 (sorry, can't upgrade yet... ;-) and we build it from source. After upgrading From Debian 8 to Debian 9, the g++ compiler seems to have upgraded from 4.9 to 6.3. The g++ 4.9 used
-std=gnu++98
as default for C++ code, but now g++ 6.3 uses-std=c++14
as default.We currently solved this problem by adding
-std=gnu++98
toQMAKE_CXXFLAGS
, but this has as a consequence that both Qt and all the projects we build using qmake are compiled with-std=gnu++98
. We would rather only build Qt with-std=gnu++98
and build our own projects using another-std
value.I tried adding
-std=gnu++98
in Qt's configure step (right before building with make), but that does not seem to work. What would be the cleanest way to build Qt using-std=gnu++98
and the rest of our code using another-std
value? -
Hi,
The probably quick and dirty way would be to modify the mkspec used to build Qt when you build it and then put it back in its original state.
Out of curiosity, why to you need Qt to be c++98 while not your other projects ?
-
@SGaist said in Building Qt 4.8.7 using g++ 6.3.0 with -std=gnu++98 on Debian 9.2.1 "stretch":
The probably quick and dirty way would be to modify the mkspec used to build Qt when you build it and then put it back in its original state.
That is indeed a quick and dirty way :-) In the meanwhile, I have discovered that the origin of the problem is that Qt 4.8.7 does not build in C++11 mode because there are parts that do not compile in C++11 mode, e.g. WebKit. See for example
https://bugreports.qt.io/browse/QTBUG-41361
https://bugreports.qt.io/browse/QTBUG-27029I think the better approach to solve this problem is to only compile the faulty Qt modules with
-std=gnu++98
(as described in https://bugreports.qt.io/browse/QTBUG-41361) by adapting their.pr[io]
files. This leaves us with the possibility to compile our own code using another-std=
value.This approach was for example also adopted in:
http://codereview.qt-project.org/95760
https://github.com/gobolinux/Recipes/blob/master/revisions/Qt/4.8.7-r2/01-gcc6_build_fix.patchOut of curiosity, why to you need Qt to be c++98 while not your other projects ?
Because for our own code, we want to use C++11/14 features, but apparently, parts of Qt 4.8.7 do not compile in C++11 mode. The only way to get Qt 4.8.7 to compile is to stick with C++98 for those incompatible modules. (And yes, I know... in an ideal world, we would already be using Qt 5.X, but that is currently not yet an option, although it is on the roadmap :-)
Feel free to ask more questions if I didn't make myself clear enough. I am open for discussion :-)
-
@Bart_Vandewoestyne said in Building Qt 4.8.7 using g++ 6.3.0 with -std=gnu++98 on Debian 9.2.1 "stretch":
In the meanwhile, I have discovered that the origin of the problem is that Qt 4.8.7 does not build in C++11 mode because there are parts that do not compile in C++11 mode, e.g. WebKit.
If you don't use that modules, perhaps you could skip building them?
-
Well, all in all, I'd go for building everything that is possible with C++11 and only the part that really can't with C++98
-
Thanks @Bart_Vandewoestyne I was running into the same problem and the information provided by you helped me to solve it.
-
Please, look at this solution.