Adding -pthread to eclipse, for using posix threads

15/02/2009

Problem

Cannot compile c/c++ project with -pthread. Eclipse is complaining about things.

Solution

Eclipse is not configured to put the -pthread argument in the gcc compilation. To solve this, go to the Menu:

Project -> Properties

From the bar on the left:

c/c++ build -> GCC C Compiler -> Miscellaneous

Add the “-pthread” argument into the beginning of the “Other Flags” Also go to:

c/c++ build -> Settings -> GCC C Linker -> Libraries

And include the “pthread”library into the other libraries. Click Apply and rebuild the project. Pthreads must work now.

There are 9 comments in this article:

  1. 23/02/2009ahmet say:

    thanks

  2. 10/04/2009rajend say:

    this one helped me too…
    thanks a lot

  3. 4/07/2009fork() a child say:

    it helped me too… thanks!

  4. 28/10/2009alex say:

    +1

  5. 21/11/2009nuno say:

    thanks a lot:D

  6. 6/01/2010vinod say:

    Thanks dude, yu rock…

    V…

  7. 23/02/2010aaron say:

    Thank you.

  8. 5/03/2010alex say:

    thanks a lot..

  9. 15/04/2010dahdash say:

    tnx ;)

Write a comment: