次のQtコンソールアプリケーションの例があります
#include <QCoreApplication>
#include <QtCore>
#include <QFuture>
#include <iostream>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
auto lambda = [](){
std::cout << "I will do some totally independent stuff here" << std::endl;
};
QFuture<void> future = QtConcurrent::run( lambda );
//i will do some concurrent work here...
future.waitForFinished();
return a.exec();
}
この .pro ファイルで
QT += core
QT -= gui
TARGET = demo
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
QMAKE_CXXFLAGS += -std=c++11 -stdlib=libc++ -mmacosx-version-min=10.8
QMAKE_CXXFLAGS += -funroll-loops -msse4.1 -O3
QMAKE_LFLAGS += -stdlib=libc++ -mmacosx-version-min=10.8
Visual C++ 2012 および Qt 4.8.5 を搭載した Windows でコンパイルおよび実行されます。指定された .pro ファイルと同じ Qt バージョンで最新の clang を使用する MacO では、次のエラー メッセージが表示されます。
13:57:18: Führe Schritte für Projekt demo aus...
13:57:18: Unveränderte Konfiguration, qmake-Schritt wird übersprungen.
13:57:18: Starte "/usr/bin/make"
clang++ -c -pipe -std=c++11 -stdlib=libc++ -mmacosx-version-min=10.8 -funroll-loops -msse4.1 -O3 -g -gdwarf-2 -arch x86_64 -Wall -W -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.8/mkspecs/unsupported/macx-clang -I../demo -I/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/usr/include -I. -I../demo -I. -F/Library/Frameworks -o main.o ../demo/main.cpp
../demo/main.cpp:16:28: error: no matching function for call to 'run'
QFuture<void> future = QtConcurrent::run( lambda );
^~~~~~~~~~~~~~~~~
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:72:12: note: candidate template ignored: failed template argument deduction
QFuture<T> run(T (*functionPointer)())
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:154:47: note: candidate template ignored: substitution failure [with FunctionObject = <lambda at ../demo/main.cpp:12:19>]: no type named 'result_type' in '<lambda at ../demo/main.cpp:12:19>'
QFuture<typename FunctionObject::result_type> run(FunctionObject functionObject)
~~~~~~~~~~~ ^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:185:47: note: candidate template ignored: failed template argument deduction
QFuture<typename FunctionObject::result_type> run(FunctionObject *functionObject)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:77:12: note: candidate function template not viable: requires 2 arguments, but 1 was provided
QFuture<T> run(T (*functionPointer)(Param1), const Arg1 &arg1)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:82:12: note: candidate function template not viable: requires 3 arguments, but 1 was provided
QFuture<T> run(T (*functionPointer)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:87:12: note: candidate function template not viable: requires 4 arguments, but 1 was provided
QFuture<T> run(T (*functionPointer)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:92:12: note: candidate function template not viable: requires 5 arguments, but 1 was provided
QFuture<T> run(T (*functionPointer)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:97:12: note: candidate function template not viable: requires 6 arguments, but 1 was provided
QFuture<T> run(T (*functionPointer)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:159:47: note: candidate function template not viable: requires 2 arguments, but 1 was provided
QFuture<typename FunctionObject::result_type> run(FunctionObject functionObject, const Arg1 &arg1)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:164:47: note: candidate function template not viable: requires 3 arguments, but 1 was provided
QFuture<typename FunctionObject::result_type> run(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:169:47: note: candidate function template not viable: requires 4 arguments, but 1 was provided
QFuture<typename FunctionObject::result_type> run(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:174:47: note: candidate function template not viable: requires 5 arguments, but 1 was provided
QFuture<typename FunctionObject::result_type> run(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:179:47: note: candidate function template not viable: requires 6 arguments, but 1 was provided
QFuture<typename FunctionObject::result_type> run(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:190:47: note: candidate function template not viable: requires 2 arguments, but 1 was provided
QFuture<typename FunctionObject::result_type> run(FunctionObject *functionObject, const Arg1 &arg1)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:195:47: note: candidate function template not viable: requires 3 arguments, but 1 was provided
QFuture<typename FunctionObject::result_type> run(FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:200:47: note: candidate function template not viable: requires 4 arguments, but 1 was provided
QFuture<typename FunctionObject::result_type> run(FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:205:47: note: candidate function template not viable: requires 5 arguments, but 1 was provided
QFuture<typename FunctionObject::result_type> run(FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:210:47: note: candidate function template not viable: requires 6 arguments, but 1 was provided
QFuture<typename FunctionObject::result_type> run(FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:216:12: note: candidate function template not viable: requires 2 arguments, but 1 was provided
QFuture<T> run(const Class &object, T (Class::*fn)())
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:221:12: note: candidate function template not viable: requires 3 arguments, but 1 was provided
QFuture<T> run(const Class &object, T (Class::*fn)(Param1), const Arg1 &arg1)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:226:12: note: candidate function template not viable: requires 4 arguments, but 1 was provided
QFuture<T> run(const Class &object, T (Class::*fn)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:231:12: note: candidate function template not viable: requires 5 arguments, but 1 was provided
QFuture<T> run(const Class &object, T (Class::*fn)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:236:12: note: candidate function template not viable: requires 6 arguments, but 1 was provided
QFuture<T> run(const Class &object, T (Class::*fn)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:241:12: note: candidate function template not viable: requires 7 arguments, but 1 was provided
QFuture<T> run(const Class &object, T (Class::*fn)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:247:12: note: candidate function template not viable: requires 2 arguments, but 1 was provided
QFuture<T> run(const Class &object, T (Class::*fn)() const)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:252:12: note: candidate function template not viable: requires 3 arguments, but 1 was provided
QFuture<T> run(const Class &object, T (Class::*fn)(Param1) const, const Arg1 &arg1)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:257:12: note: candidate function template not viable: requires 4 arguments, but 1 was provided
QFuture<T> run(const Class &object, T (Class::*fn)(Param1, Param2) const, const Arg1 &arg1, const Arg2 &arg2)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:262:12: note: candidate function template not viable: requires 5 arguments, but 1 was provided
QFuture<T> run(const Class &object, T (Class::*fn)(Param1, Param2, Param3) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:267:12: note: candidate function template not viable: requires 6 arguments, but 1 was provided
QFuture<T> run(const Class &object, T (Class::*fn)(Param1, Param2, Param3, Param4) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:272:12: note: candidate function template not viable: requires 7 arguments, but 1 was provided
QFuture<T> run(const Class &object, T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:278:12: note: candidate function template not viable: requires 2 arguments, but 1 was provided
QFuture<T> run(Class *object, T (Class::*fn)())
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:283:12: note: candidate function template not viable: requires 3 arguments, but 1 was provided
QFuture<T> run(Class *object, T (Class::*fn)(Param1), const Arg1 &arg1)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:288:12: note: candidate function template not viable: requires 4 arguments, but 1 was provided
QFuture<T> run(Class *object, T (Class::*fn)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:293:12: note: candidate function template not viable: requires 5 arguments, but 1 was provided
QFuture<T> run(Class *object, T (Class::*fn)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:298:12: note: candidate function template not viable: requires 6 arguments, but 1 was provided
QFuture<T> run(Class *object, T (Class::*fn)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:303:12: note: candidate function template not viable: requires 7 arguments, but 1 was provided
QFuture<T> run(Class *object, T (Class::*fn)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:309:12: note: candidate function template not viable: requires 2 arguments, but 1 was provided
QFuture<T> run(const Class *object, T (Class::*fn)() const)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:314:12: note: candidate function template not viable: requires 3 arguments, but 1 was provided
QFuture<T> run(const Class *object, T (Class::*fn)(Param1) const, const Arg1 &arg1)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:319:12: note: candidate function template not viable: requires 4 arguments, but 1 was provided
QFuture<T> run(const Class *object, T (Class::*fn)(Param1, Param2) const, const Arg1 &arg1, const Arg2 &arg2)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:324:12: note: candidate function template not viable: requires 5 arguments, but 1 was provided
QFuture<T> run(const Class *object, T (Class::*fn)(Param1, Param2, Param3) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:329:12: note: candidate function template not viable: requires 6 arguments, but 1 was provided
QFuture<T> run(const Class *object, T (Class::*fn)(Param1, Param2, Param3, Param4) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4)
^
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtconcurrentrun.h:334:12: note: candidate function template not viable: requires 7 arguments, but 1 was provided
QFuture<T> run(const Class *object, T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5)
^
1 error generated.
make: *** [main.o] Error 1
13:57:20: Der Prozess "/usr/bin/make" wurde mit dem Rückgabewert 2 beendet.
Fehler beim Erstellen/Deployment des Projekts demo(Kit: Desktop)
Bei der Ausführung von Schritt 'Make'
13:57:20: Verstrichene Zeit: 00:01.
このエラーが mac os で発生する理由を説明できる人はいますか? 前もって感謝します