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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:19:52+00:00 2026-06-08T04:19:52+00:00

I have 3 files , my_pipe.h , my_pipe.c , and main.c , where my_pipe

  • 0

I have 3 files , my_pipe.h , my_pipe.c , and main.c , where my_pipe is supposed to be a library .

When I compile it in Eclipse , it compiles great , with no errors , but when I run the following makefile in terminal and hit make :

exer3:  main.o libmywrapper.a

    gcc main.c libmywrapper.a -o exer3 -static -lrt



libmywrapper.a: my_pipe.o

    ar rcs libmywrapper.a my_pipe.o



main.o: main.c my_pipe.h

    gcc -lpthread -lrt -c main.c



my_pipe.o:  my_pipe.c my_pipe.h

    gcc -lpthread -lrt -c my_pipe.c

I get this :

a@ubuntu:~/Desktop/myExer$ make
gcc -lpthread -lrt -c main.c
gcc -lpthread -lrt -c my_pipe.c
ar rcs libmywrapper.a my_pipe.o
gcc main.c libmywrapper.a -o exer3 -static -lrt
libmywrapper.a(my_pipe.o): In function `shm_pipe_init':
my_pipe.c:(.text+0x61): undefined reference to `sem_init'
libmywrapper.a(my_pipe.o): In function `shm_pipe_read':
my_pipe.c:(.text+0x17f): undefined reference to `sem_wait'
my_pipe.c:(.text+0x196): undefined reference to `sem_getvalue'
my_pipe.c:(.text+0x1ba): undefined reference to `sem_wait'
libmywrapper.a(my_pipe.o): In function `shm_pipe_write':
my_pipe.c:(.text+0x4b7): undefined reference to `sem_post'
collect2: ld returned 1 exit status
make: *** [exer3] Error 1

Any idea what’s wrong with the makefile ?

Thanks

UPDATED , above!

  • 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-08T04:19:56+00:00Added an answer on June 8, 2026 at 4:19 am

    Linker options such as -lpthread and -lrt must go last in you compile line. Try:

    gcc main.o libmywrapper.a -o exer3 -static -lrt
    

    When compiling, you don’t need linker flags. E.g.:

    main.o: main.c my_pipe.h
      gcc -c main.c
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following js files in my code for EditInPlace... <?php echo $javascript->link('jquery.js');?>
I have just uploaded my published application files to my web server but I
I have a bunch of large HTML files and I want to run a
I have some files in my SVN repository that I would like to have
I have checked out files from my svn repository to a local project folder.
I have 2 css files in my page: Site.css jquery-ui.css Site.css is listed BELOW
In my Visual Studio 2010 project I have files with .mm file extension, that
I have made a Windows Service that gets installed in a c:\Program Files\My Service
I have my dot files in Github publicly. This means that I have only
I have around 1000 html files in my local computer and I have to

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.