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 6888881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:05:02+00:00 2026-05-27T06:05:02+00:00

I have ubuntu 11 installed in my system. I have a c program that

  • 0

I have ubuntu 11 installed in my system. I have a c program that uses the pthread library.
I get the error Undefined reference to sem_wait() even if I have compiled with the flag -lpthread.

for example:

gcc -lpthread prog.c

The program works fine on other ubuntu installations.

  • 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-27T06:05:03+00:00Added an answer on May 27, 2026 at 6:05 am

    Try:

    gcc -pthread
    

    instead of -lpthread. The difference is significant, I believe. The latter is linking against libpthread, the former is linking against libpthread and a bunch of other things, too!

    sem_wait is part of librt, so you could just as well use gcc -lrt, but -pthread does this for you (and everything else as well!).

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

Sidebar

Related Questions

I have ruby 1.9.2 installed on my system (Ubuntu) using rvm, but one application
I'm trying to compile a program on Ubuntu 11.10 that uses the Boost libraries.
I have an EC2 machine with ubuntu installed. I sort of messed up my
I have an Ubuntu Server (with all of LAMP and Subversion installed). I use
I am running windows 7 and have installed an Ubuntu machine using virtual box.
I have Eclipse SDK Version: 3.5.2 with EPIC 0.5.46 installed on Ubuntu Linux .
I have installed the vim-latex package using Ubuntu Synaptic package manager and updated my
I have installed Rhodecode (mercurial server) on an Ubuntu machine. I specified the repository
I have installed ipython on my Ubuntu and then I have installed mechanize on
I have ruby on rails installed on my ubuntu 8.10 desktop. Script/generate came up

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.