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.
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.
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.
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.
The code I'm tying to compile comes from http://nikhilm.github.io/uvbook/basics.html
#include <stdio.h>
#include <uv.h>
int main() {
uv_loop_t *loop = uv_loop_new();
printf("Now quitting.\n");
uv_run(loop, UV_RUN_DEFAULT);
return 0;
}
I've saved this as main.c
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.
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
This is the result of running make.
/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
I realise that this not exactly specific to libuv, but this is just where I'm at, so any help would be much appreciated.
I'm using Ubuntu 13.04