title: C - Unable to get shmget/shmat to compile
body: <p>I'm pulling out my hair trying to figure out why this isn't working on my Minix system. </p>
  
  <p>When I try to compile my C program, I get the following error:</p>
  
  <pre><code>#make
         link  pm/pm
  program.o: In function `do_function':
  program.c:(.text+0x1e): undefined reference to `shmget'
  program.c:(.text+0x36): undefined reference to `shmat'
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  *** Error code 1
  
  Stop.
  make: stopped in /usr/src/servers/pm
  #
  </code></pre>
  
  <p>This is my code:</p>
  
  <pre><code>#include &lt;sys/shm.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;sys/ipc.h&gt;
  #include &lt;sys/stat.h&gt;
  /* Some other includes here */
  
  typedef struct {
      //struct elemLi *next;
      //elem sem;
      int ref_count;
  } elemLi;
  
  int do_function(void){
      int segment_id; //Shared Memory ID
      struct elemLi* sli; //Shared Memory Pointer
      segment_id = shmget(IPC_PRIVATE, sizeof(elemLi),0660 | IPC_CREAT);
      sli = (struct elemLi *)shmat(segment_id,NULL,0);
      return -1;
  }
  </code></pre>
  
  <p>As you can see, I've included the proper header files for these calls and it's still saying the references are undefined. I was able to successfully use this in another program, so I've completely run out of ideas as to why this isn't working in this instance. </p>
  
  <p>Edit: This is within a system call. I assume that doesn't make a difference. </p>