Ubuntu 包含cs50库时使用make编译时出现问题?

Ubuntu 包含cs50库时使用make编译时出现问题?,ubuntu,makefile,clang,cs50,Ubuntu,Makefile,Clang,Cs50,我已安装了CS50库 在Ubuntu 20.04中 这段代码只是为了看看它是否有效 它的工作没有任何问题与叮当声 但是当使用make时,它不会自动链接库,所以我得到了这个错误- 我正在使用VisualStudio代码 #include <stdio.h> #include <cs50.h> int main(void) { string d = get_string("what is your name: "); printf(&qu

我已安装了CS50库 在Ubuntu 20.04中 这段代码只是为了看看它是否有效 它的工作没有任何问题与叮当声 但是当使用make时,它不会自动链接库,所以我得到了这个错误- 我正在使用VisualStudio代码

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

int main(void)
{
    string d = get_string("what is your name: ");
    printf("Hello, %s\n ",d);
}
#包括
#包括
内部主(空)
{
string d=get_string(“你叫什么名字?”);
printf(“你好,%s\n”,d);
}
爆发

mohamed@mohamed-Latitude-E5470:~/Downloads/projects$ clang hello.c -o hello -lcs50
mohamed@mohamed-Latitude-E5470:~/Downloads/projects$ make hello
cc     hello.c   -o hello
/usr/bin/ld: /tmp/ccJDbREo.o: in function `main':
hello.c:(.text+0x1e): undefined reference to `get_string'
collect2: error: ld returned 1 exit status
make: *** [<builtin>: hello] Error 1
mohamed@mohamed-Latitude-E5470:~/Downloads/projects$clang hello.c-o hello-lcs50
mohamed@mohamed-Latitude-E5470:~/Downloads/projects$make hello
cc你好,c-o你好
/usr/bin/ld:/tmp/ccJDbREo.o:在函数“main”中:
hello.c:(.text+0x1e):未定义对“get_string”的引用
collect2:错误:ld返回了1个退出状态
make:**[:hello]错误1

如何使其在使用make

时自动链接库要在CS50环境之外使用
make
您必须在项目目录中创建
makefile
文件,并在其中指定一些规则,阅读有关makefile的更多信息,可能有帮助要在CS50环境之外使用
make
,您必须在项目目录中创建
makefile
文件,并在其中指定一些规则,阅读有关makefile的更多信息,可能有帮助