Am following video from lecture Week1 Monday (45min), and using CS50 Library installed on OSX Mavericks (the appliance isn't an option as it's a work machine), but get this response to make hello-2:

cc     hello-2.c   -o hello-2
Undefined symbols for architecture x86_64:
  "_GetString", referenced from:
      _main in hello-2-3c2ca7.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: *** [hello-2] Error 1

make hello and make hello-1 both work without issue and get correct response from ./hello and ./hello-1.

Searches suggest it's a 'linker' issue but both includes files cs50.h and stdio.h seem to be linked correctly because if either reference is deleted an error occurs. string GetString(void) is in cs50.c and cs50.h. Machine is 64bit.

  • There are a lot of possibilities here. Are you using Xcode? If so, please reference this. Number 2 may have a lot to play into it. If you aren't using Xcode, please consider posting your code to pastebin with a short expiration and sharing the link so people can take a closer look.
    – bobbitworm
    Nov 22 '14 at 12:55

You never linked the CS50 library binary file to your program using the -lcs50 option on compilation!

  • Kareem-what do you mean-never linked?? my understanding is it is built in?
    – user9746
    Sep 29 '15 at 0:41
  • @Maugoshia, yes, it is linked by default on the appliance. the OP was not using the appliance.
    – kzidane
    Sep 29 '15 at 7:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .