Compiling Qt 4.8.0 with C++0x on Mac (clang)



  • Hi,

    I'm trying to compile Qt 4.8.0 on Mac OSX Lion, but I'd like to compile it with C++0x enabled. Of course, g++ 4.2 does not support this so I'm attempting to use clang. I found a clang qmake.conf file in mkspecs/unsupported (which sounds a bit ominous!) and this is the configure command I'm using:

    CXXFLAGS="-std=c++0x" QMAKESPEC="/.....(path from root)......./qt-everywhere-opensource-src-4.8.0/mkspecs/unsupported/macx-clang" ./configure --prefix=/usr/local -opensource -static -fast -qt-sql-sqlite -no-qt3support -no-webkit -graphicssystem raster -qt-zlib -qt-libtiff -qt-libpng -qt-libmng -qt-libjpeg -make libs -no-xinerama

    When I run this command, clang appears to be used during the configuration, but as soon as I run 'make', it promptly switches back to gcc and produces an 'unrecognised command line option' for the -std=c++0x flag.

    So my questions are as follows:

    1. Am I doing something wrong here? If so, what else do I need to do to compile Qt with clang?
    2. Is it actually currently possible to compile QT on Mac with clang? (I'm guessing its qmake.conf must be in 'unsupported' for some reason...)
    3. If it isn't possible, are there any other ways in which I could enable c++0x support with Qt on Mac? (I have g++4.6 from Macports, but I'm guessing that compiling Qt with it is going to be painful)

    Thanks very much in advance,
    Philip



  • Looks like I was doing something silly after all! I hadn't built it from the freshly unzipped source, meaning that even after running make confclean, the bootstrapping tools for qmake had already produced a Makefile using my previous configuration (using g++4.2). It's compiling nicely just now, I should be in the clear.



  • ...and as soon as I click 'post reply', I get a compilation error...

    here it is.

    In file included from kernel/qcursor_mac.mm:52:
    In file included from ../../include/QtGui/private/qt_cocoa_helpers_mac_p.h:1:
    ../../include/QtGui/private/../../../src/gui/kernel/qt_cocoa_helpers_mac_p.h:218:10: error: cannot initialize return object of type 'NSString *' with an rvalue of type 'const NSString *'
    { return [reinterpret_cast<const NSString *>(QCFString::toCFStringRef(qstr)) autorelease]; }
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:37:1: note: instance method 'autorelease' is assumed to return an instance of its receiver type ('const NSString *')

    • (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
      ^
      1 error generated.

    So, back to my original question... is it currently possible to compile Qt 4.8.0 on a Mac (OSX Lion), with clang and -std=c++0x? If it is, could anyone enlighten me as to what I'm missing? And if it's not, could anyone suggest an alternative c++0x compliant compiler to use on the Mac, and a method of configuring Qt to build using that compiler?

    Help would once again be much appreciated.

    Thanks very much,
    Philip



  • Here is a patch that was sent to the Qt-Interest mailing list in September 2011:

    http://lists.qt.nokia.com/pipermail/qt-interest/2011-September/035824.html

    This fixes the QtGui compile error you encountered. There may be some other build errors further down the line, though.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.