Can't make thread from a function in another file : <p>I have two files. <strong>sim.c</strong> and <strong>devices.c</strong>.</p>

<p>Here's the <strong>sim.c</strong>  </p>

<pre><code>...
#include "devices.h"

int main(int argc, char **argv) {
  pthread_t *tid;

  tid = (pthread_t *) malloc(sizeof(pthread_t) * 3);

  // this is where I start the 3 threads located in devices.c
  if (pthread_create(&amp;tid[0], NULL, device_one, NULL)) {
    exit(1);
  }
  if (pthread_create(&amp;tid[1], NULL, device_two, NULL)) {
    exit(1);
  }
  if (pthread_create(&amp;tid[2], NULL, device_three, NULL)) {
    exit(1);
  }

  // wait for 3 threads to finish
  int i;
  for (i = 0; i &lt; 3; i++) {
    if (pthread_join(tid[i], NULL)) {
      exit(1);
    }
  }
}
</code></pre>

<p>Here's <strong>devices.c</strong>  </p>

<pre><code>...
#include "devices.h"

extern void *device_one(void *arg) {
  printf("device one is called\n");
  return NULL;
}

extern void *device_two(void *arg) {
  printf("device two is called\n");
  return NULL;
}

extern void *device_three(void *arg) {
  printf("device three is called\n");
  return NULL;
}
</code></pre>

<p>And here's <strong>devices.h</strong>  </p>

<pre><code>#ifndef DEVICES_H
#define DEVICES_H

extern void *device_one(void *arg);
extern void *device_two(void *arg);
extern void *device_three(void *arg);
</code></pre>

<p>However, when I compile, I get 3 errors under sim.c saying<br>
<em>undefined reference to 'device_one'<br>
undefined reference to 'device_two'<br>
undefined reference to 'device_three'</em></p>
