Hey guys my first help thread. Hopefully it's on topic. Basically I'm reading Head First C and coding along. I'm currently at a Makefile exercise for a simple calorie calculator output. Heres the code.
hfcal.h:
Code:
void display(float weight, float distance, float coeff);
hfcal.c:
Code:
#include <stdio.h>
#include <hfcal.h>
void display(float weight, float distance, float coeff)
{
printf("Weight: %3.2F\nDistance: %3.2F\nCalories: %3.2F\n",weight,distance,coeff * weight * distance);
}
test.c:
Code:
#include <stdio.h>
#include <hfcal.h>
int main()
{
display(115.23,3.2,0.79);
return 0;
}
Makefile:
Code:
hfcal.o: hfcal.c hfcal.h
gcc -I./includes -c hfcal.c -o hfcal.o
treadmill.o: test.c
gcc -I./includes -c test.c -o treadmill.o
libcal.a: hfcal.o
ar -rcs ./libs/libcal.a hfcal.o
tread_mill: hfcal.o libcal.a
gcc treadmill.o -L./libs -lcal -o tread_mill
Current directory:
Code:
.:
hfcal.c includes libs Makefile test.c
./includes:
hfcal.h hfcal.o
./libs:
libcal.a
I get the error "make: *** No rule to make target 'hfcal.h', needed by 'hfcal.o'. Stop."
From a little googling I figure that i'm some how using the "gcc -I" dir option incorrectly, but the Makefile code is literally the answer from the book. I'm new to programming, and trying to soak up as much as possible. So any advice is appreciated.