0

For god sake this one isn't working. Can anybody help? Thanks in advance

#include <stdio.h>
#include <cs50.h>


int main(void)
{
    string s = get_string();
    printf("Hello, %s\n", s);
}

/tmp/string-38bdf3.o: In function main': string.c:(.text+0x9): undefined reference toget_string' clang: error: linker command failed with exit code 1 (use -v to see invocation)

1 Answer 1

0

Sounds like you haven't actually saved your source code before running make. Double-check that you don't see a red-dot in the tab of the source code.

If you have a very slow connection, your save might not have "registered" so if that's the case, close the source code file and then reopen it to make sure it is up to date, then try make again.

(Note that if are compiling using clang directly, rather than make, you need to add the appropriate flag(s) for the libraries you are using. In the case of the CS50 Library, you must include -lcs50 to link that library.)

2
  • we need to append -lcs50 at the end of clang command
    – nkrm
    Commented Apr 13, 2017 at 2:08
  • I assumed you were using make which does that for you.
    – curiouskiwi
    Commented Apr 13, 2017 at 2:09

You must log in to answer this question.

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