0

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
Junikin
  • 301
  • 2
  • 14
  • 1
    Have you included send.h at the top? How are you compiling this? A little more information would be helpful. – gowrath Nov 10 '16 at 23:52
  • Yes I included it. I'll post a `makefile` I made separate for easy compiling – Junikin Nov 11 '16 at 00:22
  • Its possible I am running it wrong. When I type `make` it does what is in the `makefile` but when I do the `g++` it gives me that error. **EDIT** I ran it wrong. 100% my fault – Junikin Nov 11 '16 at 00:26

0 Answers0