clang++ under QtCreator can't work with c++11

旧城冷巷雨未停 提交于 2019-12-05 16:16:43
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

After some research, I find out that the error messages could be solved by adding a flag to the .pro file

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

SOURCES += main.cpp

QMAKE_CXXFLAGS += -stdlib=libc++
QMAKE_CXXFLAGS += -std=c++11
#QMAKE_CXXFLAGS += -mmacosx-version-min=10.7 #1
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7 #2

1 and #2 do get rid of the error message

error message clang: error: invalid deployment target for -stdlib=libc++ (requires OS X 10.7 or later) but they also generate another error message

ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

symbol not found, but I have no idea what which .a should I link to?

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!