Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6744905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:08:23+00:00 2026-05-26T12:08:23+00:00

I am trying to compile gcc 4.5.1 for cygwin with support for C++0x threads.

  • 0

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:

./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:

#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

$ 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

My question is how should I configure gcc?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:08:24+00:00Added an answer on May 26, 2026 at 12:08 pm

    As you see in the error message, the problem is not with your configuration, but with your g++ option. Use

    g++ -lpthread
    

    for pthreads (POSIX threads) and

    g++ -lboost_thread
    

    for boost threads. (-pthread is wrong.)

    see the manual of g++

    man gcc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to compile a gcc project on cygwin for the first time.
I am trying to cross-compile GCC on Mac OS 10.5.7. I used this command
While trying to compile a 64 bit linux kernel using gcc, I see the
I'm trying to make my project compile under GCC (Visual Studio compiles it flawlessly).
I am trying to compile my C program in Ubuntu 9.10 (gcc 4.4.1). I
I'm trying to compile the zpipe.c example in my Linux(Ubuntu 8.04) with gcc, but
I'm getting a totally bizzare error trying to compile a C program using GCC.
I'm trying to compile this code with GCC 4.5.0: #include <algorithm> #include <vector> template
I'm trying to compile SDL_Image 1.2.10 with MinGW + MSys (gcc 4.5.0) on Windows,
I'm new to gcc, and trying to compile a c++ program which includes mysql.h

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.