Reputation: 91
all: program1 program2
program1: StringListDemo.o
gcc -Wall -std=c11 -Iinclude src/StringListDemo.c src/LinkedListAPI.c -o program1
program2: StructListDemo.o
gcc -Wall -std=c11 -Iinclude src/StructListDemo.c src/LinkedListAPI.c -o program2
Trying to compile folder with two files with main functions but keep getting error.
make: *** No rule to make target `StringListDemo.o', needed by `program1'. Stop.
Upvotes: 1
Views: 1235
Reputation: 21492
Since you mention StringListDemo.o
, but give no rule for it, make
looks for an implicit rule that tells how to update it. In other words, make
looks for StringListDemo.c
file which apparently does not exist in the current directory. However, you also mention src/StringListDemo.c
, and the program1
target apparently depends on it. So you should change StringListDemo.o
in the prerequisite list to src/StringListDemo.o
:
program1: src/StringListDemo.o
The same logic applies to program2
.
If src/StringListDemo.c
is supposed to be compiled with special options (different from defaults), then add the StringListDemo.o
target explicitly, e.g.:
StringListDemo.o: src/StringListDemo.c
gcc ...
Upvotes: 1