2013-07-12 66 views
3

我嘗試在linux上爲mingw交叉編譯一些C++ 11源代碼。該代碼使用std :: thread。在linux上交叉編譯C++ 11個線程與mingw

我編譯時總是得到一些錯誤:

$ ../mingw/cross/bin/i686-w64-mingw32-g++ -std=c++11 -I include/ test.cpp -lstdthread -otest 
In file included from test.cpp:4:0: 
... 
error: 'thread' in namespace 'std' does not name a type 
... 

我可以啓用C++ 11線程MinGW的?代碼編譯時沒有任何本地g ++的問題。

謝謝

regars 凱文

CNC中

我剛剛下載的MinGW的地方在互聯網,因爲我試圖得到一個新的儘可能版本:

../mingw/cross/bin/i686-w64-mingw32-g++ -v 
Using built-in specs. 
COLLECT_GCC=../mingw/cross/bin/i686-w64-mingw32-g++ 
COLLECT_LTO_WRAPPER=/home/bmeier/source/mingw/cross/bin/../libexec/gcc/i686-w64-mingw32/4.8.1/lto-wrapper 
Target: i686-w64-mingw32 
Configured with: /home/drangon/work/mingw-w64-dgn_32/source/gcc-4.8.1/configure --target=i686-w64-mingw32 --disable-nls --disable-multilib --with-gmp=/home/drangon/work/mingw-w64-dgn_32/build/for_cross --with-mpfr=/home/drangon/work/mingw-w64-dgn_32/build/for_cross --with-mpc=/home/drangon/work/mingw-w64-dgn_32/build/for_cross --with-isl=/home/drangon/work/mingw-w64-dgn_32/build/for_cross --with-cloog=/home/drangon/work/mingw-w64-dgn_32/build/for_cross --enable-languages=c,c++,objc,obj-c++ --disable-libstdcxx-pch --prefix=/home/drangon/work/mingw-w64-dgn_32/cross --with-sysroot=/home/drangon/work/mingw-w64-dgn_32/cross 
Thread model: win32 
gcc version 4.8.1 (GCC) 

問候 凱文

+0

gcc是否支持mingw上的C++ 11線程? – Duck

+0

您使用的是MinGW GCC的確切版本? '../mingw/cross/bin/i686-w64-mingw32-g++ -v'的輸出是什麼?並且在Linux系統上交叉編譯通常更容易(所以也許在你的機器上安裝一個Linux) –

+0

我剛剛在開始帖子中寫了版本輸出。我總是使用linux來交叉編譯:-)現在也是。我使用xubuntu。感謝您的幫助 –

回答

-1

最可能的是,你可能已經忘了,包括螺紋頭#include <thread>

1

基本上MinGW的不支持Windows線程請訪問以下鏈接:http://www.cplusplus.com/forum/windows/82461/

具體_GLIBCXX_HAS_GTHREADS沒有定義和類線在頭線程都需要它。 (它建立在gthreads上)。

你應該嘗試使用boost ::線程贏/ Linux的兼容線程類