[Interest] Several issues compiling Qt 4.8.4 with mingw-w64 4.8.1, possible related to "-std=gnu++11"
kfrank29.c at gmail.com
Mon Apr 15 20:43:22 CEST 2013
I have taken it into my head to use c++11 features with Qt. I am trying to use
the mingw-w64 port of g++, enabling the supported c++11 features with
Let me note up front that even if it is not necessary to build the Qt
"-std=gnu++11" (For safety and consistency, I prefer to do so, but some have
suggested that it is not necessary.), I will need to be able to
process Qt headers
with "-std=gnu++11" set in order to compile my own code.
I have been hitting some issues that have been reported in part in the past, but
I haven't found any clear resolution.
Any help or suggestions would be very welcome.
First, I am using the recently downloaded Qt 4.8.4 source bundle:
and a recently downloaded std::thread-enabled Ruben build of 4.8.1 g++:
The (almost) first issue I see is an ambiguous definition of swap when compiling
error: 'template<class T, class U> void QTWTF::swap(std::pair<_T1,
_T2>&, std::pair<_T1, _T2>&)' conflicts with previous using
declaration 'template<class _T1, class _T2> void
std::swap(std::pair<_T1, _T2>&, std::pair<_T1, _T2>&)'
template<typename T, typename U> inline void swap(pair<T, U>& a,
pair<T, U>& b)
I see this issue reported (with Qt 4.8.2 and mingw 4.7.1) here:
Note, this thread talks about a couple of issues, and the swap issue
is discussed at
the end. I don't see any resolution in this thread. Also, note, it
doesn't appear that
"-std=c++11", or similar, is being passed to the g++ command.
I also see a seemingly related bug listed here:
It carries the description:
"When using clang with -stdlib=libc++ option, QtScript fails to build."
and is listed as Resolved / Closed. It looks like there is a clang-directed
patch (presumably for Qt 5, but I can't tell) listed here:
I haven't tried tweaking this patch for my specific situation, but it looks
like it could work.
The next issue I see (also when compiling JSBase.cpp) is an undeclared signbit:
static member function 'static QTJSC::JSValue
error: 'signbit' was not declared in this scope
if (intVal != d || (!intVal && signbit(d)))
There are more issues, but that's enough for a start. (The build errored out on
JSBase.cpp, so I haven't gone beyond that file.)
(I should mention I already encountered and fixed the tr1 namespace issue,
namely that of having std::tr1::has_trivial_constructor defined, also mentioned
in the thread http://www.qtcentre.org/threads/50150. Oddly, it looks to me like
this issue is caused by having "-std=gnu++11" set, even though the original
poster of the http://www.qtcentre.org/threads/50150 thread did not seem to be
using "-std=gnu++11" or similar.)
I'm hoping that some or all of these issues have already been analyzed and
addressed, even if not specifically in the context of mingw-w64. Also, could
there be some common "theme" behind some or all of these issues so that
they might be addressed somehow with a "global" patch? Any advice on how
to move forward would be greatly appreciated.
More information about the Interest