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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:22:51+00:00 2026-06-07T21:22:51+00:00

Given this code : #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/wait.h> #include <unistd.h>

  • 0

Given this code :

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/shm.h>
#include <semaphore.h>
#include <pthread.h>

#define BUF_SIZE 256
int main()
{
    key_t key;
    char *virtualaddr;
    sem_t *get, *put;
    int shmid;

   const char* messageOne = "Hello world , I'm child number 1\n";
   const char* messageTwo = "Hello world , I'm child number 2\n";

   char buf[BUF_SIZE];

   key = ftok("anyfile",'R');

  shmid = shmget(key,1024,0644|IPC_CREAT);
...
...
shmctl (shmid, IPC_RMID, NULL);
exit(EXIT_SUCCESS);
}

I get from eclipse undefined reference to sem_open .

I’ve check with this post since this question is very similar to mine , but didn’t understand exactly where is my mistake ,

Can you please explain where do I need to fix it / add another compilation command (if this is indeed the case) ?

Much appreciated

  • 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-06-07T21:22:53+00:00Added an answer on June 7, 2026 at 9:22 pm

    You need to include -lpthread when compiling. This is used by the linker, to link your binary against the library.

    The other answers already cover how to do this on the command line.

    To do this in Eclipse, you need to follow the directions here:

    In the project properties, go to : C/C++ Build –> Settings. Then
    “Tool Settings”, select “Libraries” under “Linker”. You can add all
    your project libraries there (without the “-l”). Also in the lower
    part, you can add custom path to search libraries

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

Sidebar

Related Questions

Here is my code: #include <stdio.h> #include <stdlib.h> #include <dirent.h> #include <string.h> #include <sys/stat.h>
In the code given below: #include <stdio.h> #include <fcntl.h> #include <unistd.h> #include <stdlib.h> #include
I have this snippet of C code: #include<stdio.h> #include<stdlib.h> #include<string.h> typedef struct Date {
In some sample code given by a professor: #include <stdio.h> #include <string.h> #include <stdlib.h>
Why does this code segment give segmentation fault? #include <stdio.h> #include <stdlib.h> #include <sys/mman.h>
I'm facing segmentation fault problem when trying to run this code: #include<stdio.h> #include<stdlib.h> int
Given this sample code: #include <iostream> #include <stdexcept> class my_exception_t : std::exception { public:
Given this code, tableButton = new JButton(new ImageIcon(80F_FG2015.GIF)); how would I get that String
Given this code: var arrayStrings = new string[1000]; Parallel.ForEach<string>(arrayStrings, someString => { DoSomething(someString); });
Given this code: List<string> things = new List<string>(); foreach (string thing in things) {

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.