This error means that when linking, the compiler cannot find the definition of the main() function anywhere.
In your makefile, the main rule expands to something like this.
main: producer.o consumer.o AddRemove.o gcc -pthread -Wall -o producer.o consumer.o AddRemove.o
According to the gcc manual page man page , using the -o switch is described below
File -o Put output in file. This applies regardless of which output is output, whether it is an executable file, an object file, an assembler file, or pre-processed C code. If -o not specified, the default executable is placed in a.out .
This means that gcc will put the output in the file name indicated immediately next to the -o switch. So here, instead of linking all the .o files together and creating a binary [ main , in your case], it creates a binary like producer.o , linking the other .o files. Please fix this.
Sourav ghosh
source share