'thread' is not a member of 'std' in GCC 4.8

I am trying to do some C ++ 11 streaming support for my current project but am running into a bottleneck. I am using gcc 4.8.0 generated by rubenvb (downloadable directly from sourceforge) [x86_64-w64-mingw32-gcc-4.8.0-win64_rubenvb] and it doesn't seem to support C ++ 11 streaming features. The following code does not compile and does not complain 'thread' is not a member of 'std'

. From googling, there is a 4.7 experimental built-in (also rubenvb) support for std threads. My main project requires other C ++ 11 features in 4.8, I haven't tried 4.7. Please help clarify if the boot-related programming thread is enabled or not.

Platform : Window x64, Qt 4.8 (built from source using loaded gcc toolchain)

  • Since the Qt libraries are built from source, changing the toolchain would mean recompiling the entire set of libraries, which sounds bad to me. Is there something missing in both files or gcc? Thank.

Update : just download the experimental version 4.8 [x86_64-w64-mingw32-gcc-4.8-stdthread-win64_rubenvb] and the compiled test code. So now the question is:

"Is the 'experimental' version safe?"

Test code used

#include <iostream>
#include <thread>
#include <mutex> // try other c++11 threading feature

void doSomeWork( void ) { std::cout << "hello from thread..." << std::endl; }
int main() {
    std::mutex m; // also fail here
    std::thread t( doSomeWork );
    t.join();
    return 0;
}

      

and the makefile is used

CC       := g++
SRC      := test$(BUILD).cpp
OBJ      := $(SRC:.cpp=.o)
BIN      := test$(BUILD).exe
CXXFLAGS := -std=c++0x -Wall -Wextra -O0 -ggdb -lpthread -mthreads -pthread -Wno-unknown-pragmas

clean  :        ; del /a/s $(BIN) $(OBJ)
all    : $(BIN) ; del $(OBJ)
$(BIN) : $(OBJ) ; $(CC) $(CXXFLAGS) $^ -o $@
%.o    : %.cpp  ; $(CC) -c $(CXXFLAGS) $< -o $@
.PHONY: clean all

      

+3


source to share


1 answer


Mingw-Builds seems to have two different threading models if you are using the win32 one:

Mingw-Builds ( and experimental rubenvb packages ) also allow you to choose between the threading model internally used by (lib) gcc:

posix (built on winpthreads MinGW-w64s) "POSIX implementation of streams for win32 is also available in the experimental directory.

  • Its main purpose is to support C ++ 11 standard streaming, which only supports POSIX streams. " Http://mingw-w64.sourceforge.net/
  • includes the capabilities of the C ++ 11 library contained in the header stream, mutex and future.
  • Performance degradation in specific scenarios. The C ++ 11 functionality is significantly slower than the Win32 implementation or even the MSVS2012s implementation.

win32 uses native Win32 streams functions.

  • no C ++ 11 thread, mutex or future
  • best performance


Source: http://qt-project.org/wiki/MinGW-64-bit

+2


source







All Articles