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

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.

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.

What does one do to get C++0x threading support with GCC?
Use Boost? Seriously http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html claims threads aren't complete even in mainline head so it isn't going to be in any current release.

The native Windows builds of gcc do not support the new C++0x/C++11 thread library.
The (commercial) Just::Thread library adds support to the TDM port of gcc 4.5.2 for Windows, as well as MSVC.

Use this builts of mingw: http://code.google.com/p/mingw-builds/downloads/list

There is already a lightweight header-only library that implements std::thread and sync primitives in pure win32 API:
https://github.com/meganz/mingw-std-threads
IT should work with any version of MinGW that has proper C++11 support.

Related

On Linux, what's the use of installing clang++ if it uses g++ libs only?

For C++ development on Linux, if I install clang and use it; it actually uses libstdc++(the g++ lib). What's the use of installing the frontend compiler clang on linux then?
I should be good with gcc/g++ only on a linux machine as that's a complete toolchain!
Note: I'm not an expert in C++.
libstdc++ is a default runtime on your Linux. libc++ is not installed by default. If you link your app to libc++, you have to add it as a runtime dependency.
You are right, gcc/g++ is good for Linux, moreover its diagnostic messages are more clear, thus the compiler is better for beginners. By using clang++, you need to know the C++ standard deeper, otherwise it's difficult to get an error reason.

MinGW g++ 4.8.1-4 doesn't recognize -std=c++14

I installed MinGW by following their home page to their sourceforge and using mingw-get-setup.exe. This installed g++ 4.8.1-4. GCC 4.8 is supposed to support C++14 with a command-line switch, but I just get an "unrecognized option" error.
Is this a bug with MinGW? With GCC? What can I do about it? Since I know someone will ask, I want C++14 for its for-each loops. I'm using iterators for now, but for-each would improve both readability and writability.
EDIT: Found out my g++ build supports c++11, so I can use for-each. But still no luck on c++14 support.
g++ 4.8 simply does not support C++14, also MinGW is quite outdated when there are more new versions of gcc.
Alternatives you can use
If you want really to use C++11 or C++14 on windows with gcc you should be using one of the following options:
https://msys2.github.io/ (Uses MinGW-w64 internally).
http://mingw-w64.org/doku.php (it supports 32-bits too).
http://tdm-gcc.tdragon.net/.

Xcode tools on Mac support c++11?

I do most of my coding using Qt in C++ and have noticed that I get x86 architecture not found errors when I enable support for C++11 in my Qt .pro files.
I have the latest Ver of Xcode and have developer tools installed. I realize that OSX uses clang but it still seems that I am still stuck with OSX only supporting earlier versions of gcc.
Is there a reason we can't get these updates from Xcode, and if not I guess I need to install these updates myself?
You can use clang with this FLAGS -std=c++11 -stdlib=libc++ to use C++11 features, another similar question can be found here

Compile C++11 code on mac?

I'm new to C++11. I've tried:
clang++ -std=c++11 -stdlib=libc++ *.cc
It works, but my questions is:
Is there anyway to set these flag as default for clang++?
How to update g++ 4.2 to a version that supports C++11?
Which way do you think it's the best to compile C++11 code on mac?
Thanks.
Brett has described how to install GCC it with MacPorts. Here’s how to do it with Homebrew, which styles itself (rightfully!) as a modern replacement of MacPorts:
brew tap homebrew/versions
brew install --enable-cxx gcc48
As far as I know the easiest way to install the most recent Clang is by downloading the compiled version linked in dsign’s answer – and, as Brett mentioned, since Apple uses clang internally it’s not advised to tinker with that installation – just put yours somewhere else.
Concerning what the “best” compiler is there are two things to consider in addition to what Brett has already said:
GCC is much older and more mature than Clang. Internal compiler errors do happen occasionally in Clang. That said, it’s maturing rapidly because it’s being pushed by several companies.
Clang is feature complete for C++11, GCC 4.8 is not. One very obvious example of this is the fact that GCC 4.8 still has no working <regex> implementation, which is a shame.
Outside of an IDE (e.g., in shell), I normally have the variable CXX set to: "clang -std=c++11 -stdlib=libc++" in .profile / .tcshrc / etc., since this is picked up by most configure scripts too. On the cmd line I might use: $CXX -c foo.cc
MacPorts gcc-4.8.1 works well: "[sudo] port install gcc48 [-universal]"
"[sudo] port select --set gcc gcc48" will make this the default gcc, g++, etc.
Don't attempt to update or modify the system tools, like the old gcc-4.2 / llvm hybrid that comes with Xcode.
I don't know what you mean by 'best' way in the 3rd part of your question, but with Apple's support (they employ the primary author of LLVM), and other projects like FreeBSD behind it, clang will only continue to improve. It's already much faster than gcc, has far better error messages / diagnostics (especially for C++ and templates), and a modular architecture. For OS X, it's the clear choice.
Answers:
I don't think so
You install another g++ version alongside 4.2, it is bad karma to remove the one that comes with the system. To install a new one, check this
Same goes for clang. You can download it here.
In general, I totally recommend that you get better g++ compilers, 4.2 is quite old and its code quality is not as good. And using c++ 11 is totally worth it.
Do it all in Xcode's build settings like most Apple developers. Xcode simplifies life in many ways.

Where can I download GCC 4.3.2 binaries for Windows?

I have to write a c++ program, and i want to do this in vstudio 2010, because it's the most comfortable way for me. But later this code will be compiled in gcc 4.3.2 (ejudge). I can't find gcc 4.3.2 binaries for Windows, if there any ways to check correctness of gcc compilation? Or maybe anyone will help to find gcc binaries? I found this link http://tdm-gcc.tdragon.net/download but there i can't find 4.3.2 version binaries, only source code. Thanks.
MinGW, or Minimalist GNU for Windows, is a set of GNU compilers for Windows platforms. It's the easiest way to use G++ on windows platform. You could also use Cygwin, but it would be a bit of overkill.
As I recall g++ 4.3.2 was used in an older version of the Code::Blocks IDE, as the bundled compiler.
However, I'm currently unable to connect to [http://www.codeblocks.org], so I don't know if they provide downloads of older versions.