Did a Mac update ruin my ability to use gcc?

I am trying to compile two c files into one executable. In the directory I have only three files; Makefile, main.c and myfunction.c.

Makefile:

CC = gcc
CFLAGS = -Wall -g -O0
LIBS = -lm
SRCS = $(wildcard *.c)
OBJS = $(SRCS:.c=.o)
MAIN = main

all: $(MAIN)
    @echo  Program has been compiled

$(MAIN): $(OBJS) 
    $(CC) $(CFLAGS) $(INCLUDES) -o $(MAIN) $(OBJS) $(LIBS)

clean:
    $(RM) *.o *~ $(MAIN)

main.c:

#include <stdio.h>
void myfunc();
int main (int argc, char *argv[]) {
    myfunc();
    return 0;
}

myfunction.c:

#include <stdio.h>
void myfunc() { printf("hello world"); }

output after make:

gcc -Wall -g -O0   -c -o main.o main.c
gcc -Wall -g -O0   -c -o myfunction.o myfunction.c
gcc -Wall -g -O0  -o main main.o myfunction.o -lm
Undefined symbols for architecture x86_64:
  "_myfunc", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [main] Error 1

I had something nearly identical working in the past. I have since clean installed MacOS and updated to Big Sur. Is this the issue or have I overlooked something?

2 answers