I was working on an assignment that simulates semaphores by performing wait()
and signal()
operations. When I went to compile I got this message
Undefined symbols for architecture x86_64:
"signal_sem(sim_sem_data*)", referenced from:
child(void*) in diamond-7a2227.o
mother() in diamond-7a2227.o
"create_sim_sem(int)", referenced from:
init() in diamond-7a2227.o
"wait_sem(sim_sem_data*)", referenced from:
child(void*) in diamond-7a2227.o
mother() in diamond-7a2227.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The professor included separate files named sem.h
and sem.cpp
that allow for functions like the ones referenced in the error message.
My reason for posting is that while I thought I was just doing it wrong, my past projects that use those functions and files don't work anymore either. What does this error mean then?
Thanks in advance for all answers
MAKEFILE
diamond: diamond.o sem.o
g++ -o diamond diamond.o sem.o
diamond.o: diamond.cpp sem.h
g++ -c diamond.cpp
sem.o: sem.cpp sem.h
g++ -c sem.cpp