1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

sem.h Problem

Discussion in 'C' started by icu222much, Feb 7, 2010.

  1. icu222much

    icu222much New Member

    Joined:
    Feb 7, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    I am trying to program with semaphores and was told that I should use sem.h. When I compile, I get the error: "sys/sem.h: No such file or directory". How can I fix my problem?

    Code:
    #include <stdio.h>
    #include <sys/sem.h>
    
    
    int main() {
        printf("I am alive \n");
        getchar();
        return 0;
    }
    
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,292
    Likes Received:
    365
    Trophy Points:
    83
    Remove that line
     
  3. icu222much

    icu222much New Member

    Joined:
    Feb 7, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Removing that line would get rid of the error, but I still would like to use semaphores.
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,292
    Likes Received:
    365
    Trophy Points:
    83
    But if that file isn't there in your system and so having that file is not the way out.
     
  5. icu222much

    icu222much New Member

    Joined:
    Feb 7, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    How would I get that file onto my computer?

    I found sem.h, downloaded it, and placed it in the directory (C:\Program Files (x86)\CodeBlocks\MinGW\include). When I ran my program, the compiler said there were lots of problems with sem.h. After doing some research, I found out that I can't just add sem.h as this is just a 'pointer' file which is suppose to point to the actual code behind this function. I am trying to find how to get the actual code on my computer.

    Sorry, I am very new to programming in C.
     
  6. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,292
    Likes Received:
    365
    Trophy Points:
    83
    If you are new try your hands on basics as that file may be in some external package which you may need to install
     
  7. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England

Share This Page