title: How can I compile a minimum program with libuv?
body: <p>It's been quite a while since I wrote a program in C, and even so I always found the actual compiling and linking quite confusing.</p>
  
  <p>Since I've been playing / working with node.js lately, I have become curious enough to start taking a peek under the hood and am currently looking at libuv.</p>
  
  <p>I've found some excellent guides, but have found the actual compiling part has been largely skipped over. Mostly likely due to the fair assumption that whoever is interesting probably works with gcc a lot.</p>
  
  <p>I've downloaded the latest libuv from gtihub as a zip and have unzipped in into a working folder. I compiled and installed it following README.md. All this went fine and without an any issues.</p>
  
  <p>The code I'm tying to compile comes from <a href="http://nikhilm.github.io/uvbook/basics.html" rel="nofollow">http://nikhilm.github.io/uvbook/basics.html</a></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;uv.h&gt;
  
  int main() {
      uv_loop_t *loop = uv_loop_new();
  
      printf("Now quitting.\n");
      uv_run(loop, UV_RUN_DEFAULT);
  
      return 0;
  }
  </code></pre>
  
  <p>I've saved this as main.c</p>
  
  <p>This is the Makefile I am using, which I suspect is the problem as it's cobbled together from various sources and my knowledge in this area is cloudy to say the least.</p>
  
  <pre><code>main: main.c
      gcc -g  -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I./libuv-master/include/ -o main main.c -pthread -lrt -lm
  clean:
      rm main
  </code></pre>
  
  <p>This is the result of running make.</p>
  
  <pre><code>/tmp/ccJbU03z.o: In function `main':
  /home/tom/libuv-test/main.c:5: undefined reference to `uv_loop_new'
  /home/tom/libuv-test/main.c:8: undefined reference to `uv_run'
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>I realise that this not exactly specific to libuv, but this is just where I'm at, so any help would be much appreciated.</p>
  
  <p>I'm using Ubuntu 13.04</p>