Ich bin eine einfache Anwendung Cross-kompilieren für Windows versucht:MinGW Fehler: 'Faden' ist kein Mitglied von 'std'
#include <thread>
void Func(){
return;
}
int main(){
std::thread thr1(Func);
thr1.detach();
return 0;
}
Und das ist, was ich bekommen:
$ i686-w64-mingw32-g++ -static-libstdc++ -static-libgcc -pipe -g -std=c++0x ./threadstutor.cpp
./threadstutor.cpp: In function ‘int main()’:
./threadstutor.cpp:8:3: error: ‘thread’ is not a member of ‘std’
./threadstutor.cpp:8:15: error: expected ‘;’ before ‘thr1’
./threadstutor.cpp:9:3: error: ‘thr1’ was not declared in this scope
Eigentlich hat dieser Code kein solches Problem, wenn er mit g ++ für Ubuntu kompiliert wird; aber ich muss für Windows Cross-kompilieren, und hier bin ich fest.
Wenn Sie dies unter Windows kompilieren, benötigen Sie Mingw-Builds v4.8.1 mit Posix-Threads: http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.1/64 -bit/threads-posix/sjlj/Sie können zwischen sjlj und seh wählen. Seh ist nur x64 und sjlj ist sowohl x32 als auch x64. – Brandon
@CantChooseUsernamen Ich kompiliere es auf Ubuntu. Ich habe den neuesten Mingw aus dem Repository; _ "i686-w64-mingw32-g ++ - Version" _ sagt _ "i686-w64-mingw32-g ++ (GCC) 4.6.3" _ –
@CantChooseUsernamen obwohl wenn ich die Lösung nicht finden konnte, könnte ich es als verwenden eine Art Workaround: Führen Sie MinGW durch Wine aus, um die Quelle zu kompilieren. Obwohl es seltsam ist: D Übrigens unterstützt meine Version des Compilers nicht _std :: thread_s? –