16,814
社区成员




#-------------------------------------------------
#
# Project created by QtCreator 2013-02-06T07:23:32
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = test00
TEMPLATE = app
CONFIG += -std=gnu++11
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
#include <functional>
#include <iostream>
#include <memory>
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
auto A = 444; //警告,
std::cout<<A<<std::endl;
std::unique_ptr<int> B; //错误讯息
return a.exec();
}
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
QMAKE_CXXFLAGS += -std=c++0x
codes
#include <functional>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
template<typename T>
inline void print_comma_separated_list(T value)
{
std::cout<<value<<std::endl;
}
template<typename First,typename ... Rest>
void print_comma_separated_list(First first,Rest ... rest)
{
std::cout<<first<<",";
print_comma_separated_list(rest...);
}
constexpr int multiply_two(int a)
{
return a * 2;
}
int main()
{
// insert code here...
std::cout << "Hello, World!"<<std::endl;
auto func = [](){ std::cout << "hahaha\n"; };
func();
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);
for(auto const &data : strs2){
std::cout<<data<<std::endl;
}
std::unique_ptr<int> A(new int(3));
std::cout<<*A<<std::endl;
print_comma_separated_list(32, "444", 34.564564, "lalamimilolipo");
return 0;
}
透过QtCreator编译,一切正常
但是若使用了跟Qt有关的部分
会跑出warning
ld: warning: directory not found for option '-F/Users/yyyy/Qt5.0.1/5.0.1/clang_64/qtbase/lib'
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
QMAKE_CXXFLAGS += -stdlib=libc++
QMAKE_CXXFLAGS += -std=c++11
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7 #1
不加#1的话,会跑出
invalid deployment target for -stdlib=libc++ (requires OS X 10.7 or later)
这条错误讯息,但是加上去以后则会出现
clang: error: linker command failed with exit code 1 (use -v to see invocation)
这条错误讯息
连接错误,但是透过commend line编译就link得很顺利
makefile的内容 http://pastebin.com/CaiFdNtF
看不出所以然
不会要我去检查mkspec的内容吧
int main(int argc, const char * argv[])
{
// insert code here...
std::cout << "Hello, World!\n";
auto func = [](){ std::cout << "hahaha\n"; };
func();
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);
for(auto const &data : strs2){
std::cout<<data<<std::endl;
}
std::unique_ptr<int> A(new int(3));
std::cout<<*A<<std::endl;
print_comma_separated_list(32, "444", 34.564564, "lalamimilolipo");
return 0;
}
.pro file
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
CONFIG += -std=c++11
SOURCES += main.cpp
输入
which clang++
的结果是 /usr/bin/clang++
这跟我QtCreator设定的compiler一致,但是用QtCreator编译却一直不过关
难道是QtCreator的设定错误了吗?