Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
234 views
in Technique[技术] by (71.8m points)

c++ - GCC std::thread not found in namespace std

I am using GCC 4.5.0 with the Eclipse IDE (if that matters) on Windows via MinGW.

I'm using the -std=c++0x flag.

I find that _GLIBCXX_HAS_GTHREADS still isn't defined, so thread for me still isn't a member of namespace std. -- or perhaps it is something else.

What does one do to get C++11 threading support with GCC?

P.S. It doesn't recognize the -pthread flag. I read in a question elsewhere on this site that this works.

Edit: Stupid me: pthread is a library, not an option. It's installed, gcc can find the header, but still no cigar.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Works fine on Linux (g++ -std=c++0x -lpthread with no additional defines).

However, this thread on Cygwin mailing list suggests that, at least as of 4.4, _GLIBCXX_HAS_GTHREADS was disabled by an autoconf test when building libstdc++ because pthread implementation of cygwin is missing pthread_mutex_timedlock. Perhaps MinGW has the same problem.

Also, this thread on comp.lang.c++.moderated says the same thing. Not supported by the library.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...