Reputation: 23
I'm trying to compile something and include the pthread library in my makefile, but it doesn't seem to put it on the command line. If i type it directily into the command line it compiles, but if I try to use my makefile it comes up with errors along the lines of undefined refernce to pthread_join and such.
Here is my makefile
CC=gcc
all: pthreads
pthreads: pthreads.c
gcc -o pthreads pthreads.c -lpthread
Upvotes: 1
Views: 82
Reputation: 80921
You are missing the s
on the target line (i.e. you have pthread:
). So your rule isn't being run. The default (built-in) make rule is (and that rule doesn't have the -lpthread
bit).
You can either fix your typo or put -lpthread
in LDLIBS
and let the built-in rule do the compilation and linking for you.
Upvotes: 1