[RESOLVED] gcc 4.5.1 C++0x thread support
Hi,
I am trying to compile gcc 4.5.1 for cygwin with support for C++0x threads.
However, the resulting gcc does not recognize the -pthread option.
My configure command is:
Code:
./configure --enable-bootstrap --enable-shared --enable-shared-libgcc --with-gnu-ld --enable-languages=c,c++ --enable-libgomp --enable-libssp --enable-threads=posix --with-__thread
The sample program is:
Code:
#include <iostream>
#include <thread>
using namespace std;
void hello()
{
cout << "Hello Concurrent World!" << endl;
}
int main()
{
cout << "starting" << endl;
thread t(hello);
t.join();
cout << "ending" << endl;
return 0;
}
I am compiling a C++ program using
Code:
$ gcc -Wall -g -std=c++0x -pthread Trial.cpp
gcc: unrecognized option '-pthread'
Trial.cpp: In function `int main()':
Trial.cpp:21:5: error: `thread' was not declared in this scope
Trial.cpp:21:12: error: expected `;' before `t'
Trial.cpp:22:5: error: `t' was not declared in this scope
Can anybody tell me if there is any option I missed to enable thread support?
Re: gcc 4.5.1 C++0x thread support
According to this page:
http://gcc.gnu.org/projects/cxx0x.html
it looks like the gcc support for concurrency is still fairly minimal. I don't think that page covers what's been done with the gcc standard library though.
Re: gcc 4.5.1 C++0x thread support
I was unaware that there was a gcc for Windows, I thought it was MinGW. MinGW doesn't come with the pthreads libraries I don't think, you have to get it.
Re: gcc 4.5.1 C++0x thread support
"-pthread" should be a synonym for "-pthreads". Try it with an s on the end.
>> I was unaware that there was a gcc for Windows [other than MinGW]
It's more "gcc for Cygwin" - which provides a Posix environment on Windows.
http://www.cygwin.com/
gg
Re: gcc 4.5.1 C++0x thread support
Thank you all. gcc supports C++0x thread since its 4.3 version
http://stackoverflow.com/questions/3...in-eclipse-cdt
I have read a couple of other blogs using gcc with this feature. So, I think I am just making some mistake in configuring the gcc. Unfortunately the gcc binaries that are available for cygwin are old. So, I need to compile from source.
Re: gcc 4.5.1 C++0x thread support
Quote:
Originally Posted by
Codeplug
"-pthread" should be a synonym for "-pthreads". Try it with an s on the end.
gg
I tried it, but that option is also not recognized. I am aware that pthreads is a separate library and I can link using -lpthreads, but this C++0x thread is library separate from the pthreads though it is just a wrapper on that on Posix systems.
Re: gcc 4.5.1 C++0x thread support
I found this link that says cygwin does not support pthread_mutex_timedlock function. So, the C++0x threading support is disabled in cygwin.
http://stackoverflow.com/questions/3...thread-problem