Closed danli349 closed 10 months ago
My source file is hello.c:
hello.c
#include <stdio.h> #include <cs50.h> int main(void) { int n = get_int("Prompt: "); printf("hello world! %d \n", n); }
I can compile it using gcc hello.c -lcs50 -o hello, and run ./hello successfully.
gcc hello.c -lcs50 -o hello
./hello
but I failed to compile it using make hello: the error is
make hello
hello.c:(.text.startup.main+0xf): undefined reference to `get_int' collect2: error: ld returned 1 exit status make: *** [<builtin>: hello] Error 1
How should I fix it?
See https://github.com/cs50/cli/blob/caa47904d30674ba2da4de90febc7434e140f079/etc/profile.d/cli.sh#L46-L48!
My source file is
hello.c
:I can compile it using
gcc hello.c -lcs50 -o hello
, and run./hello
successfully.but I failed to compile it using
make hello
: the error isHow should I fix it?