[Interest] Several issues compiling Qt 4.8.4 with mingw-w64 4.8.1, possible related to "-std=gnu++11"

K. Frank kfrank29.c at gmail.com
Mon Apr 15 20:43:22 CEST 2013


Hello List!

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
"-std=gnu++11".

Let me note up front that even if it is not necessary to build the Qt
libraries with
"-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:

   qt-everywhere-opensource-src-4.8.4.zip

and a recently downloaded std::thread-enabled Ruben build of 4.8.1 g++:

   x86_64-w64-mingw32-gcc-4.8-stdthread-win64_rubenvb.7z

The (almost) first issue I see is an ambiguous definition of swap when compiling
..\3rdparty\javascriptcore\JavaScriptCore\API\JSBase.cpp:

   ..\3rdparty\javascriptcore\JavaScriptCore/wtf/HashTable.h:264:83:
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:

   http://www.qtcentre.org/threads/50150

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:

   https://bugreports.qt-project.org/browse/QTBUG-26228

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:

   https://qt.gitorious.org/qt/qtscript/commit/48baeef0766ba145d26d374561e152b40245f3b8

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:

   ..\3rdparty\javascriptcore\JavaScriptCore\runtime/JSImmediate.h: In
static member function 'static QTJSC::JSValue
QTJSC::JSImmediate::from(double)':
   ..\3rdparty\javascriptcore\JavaScriptCore\runtime/JSImmediate.h:493:49:
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.


Thanks.


K. Frank



More information about the Interest mailing list