CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Threaded View

  1. #1
    Join Date
    Oct 2008
    Location
    Singapore
    Posts
    195

    [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?
    Last edited by rohshall; August 23rd, 2010 at 02:59 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured