4

OS : OS X 10.8.1 QtCreator : 2.6.2

Command line is fine, but QtCreator fail to compile the codes.

#include <functional>
#include <iostream>
#include <memory>
#include <string>
#include <vector>

int main(int argc, const char * argv[])
{
    std::vector<std::string> strs{"yahoo", "haha"};
    for(auto const &data : strs){
        std::cout<<data<<std::endl;
    }

    std::vector<std::string> strs2 = std::move(strs);

    std::unique_ptr<int> A(new int(3));
    std::cout<<*A<<std::endl;

    return 0;
}

Command line :

clang++ -stdlib=libc++ -std=c++11 main.cpp -o test

Compiler setting of QtCreator http://www.flickr.com/photos/92283971@N04/8453188038/in/photostream

Qt .pro file

TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt

SOURCES += main.cpp

QMAKE_CXXFLAGS += -std=c++11 
QMAKE_CXXFLAGS += -stdlib=libc++

Error message:

clang: error: invalid deployment target for -stdlib=libc++ (requires OS X 10.7 or later) make: *** [main.o] Error 1

But my OS number is 10.8.1

slava
  • 1,901
  • 6
  • 28
  • 32
StereoMatching
  • 4,971
  • 6
  • 38
  • 70

2 Answers2

4
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt

SOURCES += main.cpp

LIBS += -stdlib=libc++

QMAKE_CXXFLAGS += -stdlib=libc++
QMAKE_CXXFLAGS += -std=c++11
QMAKE_CXXFLAGS += -mmacosx-version-min=10.7
QMAKE_LFLAGS += -mmacosx-version-min=10.7

I can compile the codes by this .pro file But there are warning when you play with Qt library

ld: warning: directory not found for option ‘-F/Users/yyyy/Qt5.0.1/5.0.1/clang_64/qtbase/lib’ After some research, I find out this is a bug of Qt5 It is ok if you ignore this warning message even it is annoying

StereoMatching
  • 4,971
  • 6
  • 38
  • 70
0

This seemed to do the trick for me.

CONFIG += c++11

It correctly put -std=c++11 in the command line and I didn't get any compiler or linker errors.

Using Qt 5.2.