This is the error when I run make:
Undefined symbols for architecture arm64:
"\_add", referenced from:
\_main in a4-1-989722.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: \*\*\* \[a4-1\] Error 1
note (one of the functions in my module is add()
This is the makefile:
CC = gcc
CFLAGS = -Wall -Wextra -pedantic
TARGET = a4-1
DEP1 = myMath
all: $(TARGET)
debug: CFLAGS += -DDBUG
debug: $(TARGET)
&(TARGET): $(TARGET).c $(DEP1).o
$(CC) $(CFLAGS) $(DEP1).o -o $(TARGET) $(TARGET).c
$(DEP1).o: $(DEP1).c
$(CC) $(CFLAGS) -c $(DEP1).c
clean:
rm $(TARGET) *.o
This is the module .c file:
#include <stdio.h>
#include <stdlib.h>
int add(int x, int y)
{
return(x + y);
}
This is the module .h file:
int add(int, int);
module.c? Because in that case, I have no idea what it has to do with the question, as the makefile given does not reference any such file. For its part, the makefile is either mangled or flat wrong, as each line in the recipe part of amakerule must be indented with a leading tab character, and there is no sign of any indentation of any kind in the makefile presented.&before the$(TARGET)rule which is certainly wrong, and the output quoted here has bizarre backslashes before various characters. Also, it's weird to have a program depend on one.ofile and one.cfile, then link together the.owith the compiled.cfile. It's not wrong, probably, but it's weird.