0

I've been trying to do one of the sample programs in lecture 1 and keep being prompted with the same error. However, when running a simple "Hello, world" program it executes fine. I've installed everything from the YouTube tutorial on setting up a local environment. This is my code:

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

int main(void) { string answer = get_string("What is your name? ");

printf("Hello, %s\n", answer); }

This is the error: gabrieltierra@gabriels-mbp-2 cs50 % make hello cc hello.c -o hello Undefined symbols for architecture arm64: "_get_string", referenced from: _main in hello-86b783.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [hello] Error 1

Please help!!!

2 Answers 2

0

The linker cannot find the get_string() function (which is defined in the CS50 library). From your code it appears that both #include directives are on the same line? Please make sure they are 2 lines - e.g.

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

int main(void) 
{ 
    string answer = get_string("What is your name? ");

    printf("Hello, %s\n", answer); 
}
0

First, as already said, the two #import at the beginning of the file should be on a separate line.

Otherwise, I just answered the same question in the following thread: https://stackoverflow.com/a/74815579/8847198

You must log in to answer this question.

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