Qt 5, C++11, and mac?



  • I'm using qmake to build my project. I'm using
    Mac 10.7.5
    Xcode Version 4.3.3
    Qt 5

    in ".pro"
    @QT += core
    QT -= gui

    --------- Project Settings -------------

    TEMPLATE = app
    TARGET = test
    CONFIG -= app_bundle
    CONFIG += console
    CONFIG += c++11 # <----- it doesn't work
    SOURCES += main.cpp@

    I'm still getting errors. The compiler doesn't know where are the header files for C++11.
    Any suggestions?


    In Xcode, I have to do the following settings
    Build Options:
    Compiler for C/C++/Objective-C --------------> Apple LLVM compiler 3.1
    Apple LLVM compiler 3.1 - Language:
    C++ Language -------------> C++11[-std=c++11]
    C++ Standard Library --------------> libc++ (LLVM C++ standard library with C++11 support)



  • Hi,
    Maybe post this question in the tools forum instead of the General forum. There they might have an idea.



  • [quote author="Jeroentje@home" date="1393493243"]Hi,
    Maybe post this question in the tools forum instead of the General forum. There they might have an idea.
    [/quote]

    Should I remove it or just post another post?



  • Hi, try to add this line to your .pro file:
    @MAKE_CXXFLAGS += -std=c++0x -stdlib=libc+@

    (you need this line if you are using Qt earlier than 5.2)
    (also try to update your Xcode to v.5)



  • [quote author="hskoglund" date="1393493638"]Hi, try to add this line to your .pro file:
    @MAKE_CXXFLAGS += -std=c++0x -stdlib=libc+@

    (you need this line if you are using Qt earlier than 5.2)
    (also try to update your Xcode to v.5)
    [/quote]

    It doesn't work.



  • Hmmm, I had the same problem last year with Qt 5.1.

    Since then I've upgraded my project to Qt 5.2.1 and Xcode 5.02 and now I only need that line in my .pro file: (same as yours, works ok)
    @config += c++11@

    Also make sure it is a small c and not a capital C "see my blog post":http://www.tripleboot.org/?p=101



  • Still no hope. I'm not using Xcode 5.02, I'm not certain if this is the problem.



  • In Xcode, I have to do the following settings
    Build Options:
    Compiler for C/C++/Objective-C ———————> Apple LLVM compiler 3.1
    Apple LLVM compiler 3.1 – Language:
    C++ Language ——————-> C++11[-std=c++11]
    C++ Standard Library ———————> libc++ (LLVM C++ standard library with C++11 support)


  • Moderators

    You need to inform Qt that libc++ is used instead of libstdc++.



  • [quote author="sierdzio" date="1393494925"]You need to inform Qt that libc++ is used instead of libstdc++.[/quote]

    How?


  • Moderators



  • Still not working. :'(



  • I'm guessing here but I seem to remember, LLVM 3.1 was a bit too old for proper C++11 support, so when LLVM 3.2 came out late 2012, C++11 worked much better in Xcode.

    Why not trying upgrade your Xcode... it is not so expensive :-)

    EDIT: since you're on Lion, Xcode 5 is not kosher, instead you can update to Xcode 4.6.3, which comes with LLVM 3.2 as well.



  • [quote author="hskoglund" date="1393496084"]I'm guessing here but I seem to remember, LLVM 3.1 was a bit too old for proper C++11 support, so when LLVM 3.2 came out late 2012, C++11 worked much better in Xcode.

    Why not trying upgrade your Xcode... it is not so expensive :-)

    EDIT: since you're on Lion, Xcode 5 is not kosher, instead you can update to Xcode 4.6.3, which comes with LLVM 3.2 as well.[/quote]

    I can't upgrade Xcode because my mac version < 10.8 (really sad)



  • And g++ is giving me this erros
    cc1plus: error: unrecognized command line option "-stdlib=libc++"
    cc1plus: error: unrecognized command line option "-std=c++0x"



  • (just edited my prev. post): yeah, I forgot you're on Lion, but as I said, Xcode 4.6.3 is the one you could try...



  • C++11 is working in Xcode, but I'm facing problem with the proper settings for qmake project. I've posted the settings in Xcode for c++11


Log in to reply
 

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