Makefile question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Makefile question

I make a simple makefile that i can use to compile my files. The instruction of that makefile are like this: $(CC)=gcc final: main.o Stack.o $(CC) main.o Stack.o -o test main.o: $(CC) -c main.c Stack.o: include/Stack.c include/Stack.h: $(CC) -c include/Stack.c clean: rm rf *o final This works on my raspbian, but in order to work i need to introduce the include folder(the folder i created) here there are the files Stack.c and Stack.h. There is a easy way to do this without the need of using always include/?

5th Nov 2023, 5:06 PM
Werg Serium
Werg Serium - avatar
1 Answer
+ 1
CC = gcc SRC_DIR = include final: main.o Stack.o $(CC) main.o Stack.o -o test main.o: main.c $(CC) -c
lt; -I$(SRC_DIR) Stack.o: $(SRC_DIR)/Stack.c $(SRC_DIR)/Stack.h $(CC) -c
lt; -I$(SRC_DIR) clean: rm -rf *.o final
13th Nov 2023, 3:41 PM
Brijesh Bagthaliya
Brijesh Bagthaliya - avatar