我注册了CS50。我正在做第一周的项目。程序顶部的#include应该已经定义了某些程序,如get_string、get_int等。在我进入项目之前,我运行了一个简单的测试,以确保一切正常。
#include <cs50.h>
#include <stdio.h>
int main(void)
{
printf("What is your name?\n");
string x = get_string("x");
printf("Hello, %x!");
} 我的代码在上面和下面是我不断收到的错误。
undefined reference to `get_string'
clang-7: error: linker command failed with exit code 1 (use -v to see invocation)当我放入#include时,这些错误不是已经被引用了吗?
发布于 2019-09-16 08:19:45
这是一个链接器错误,而不是一个编译器错误。问题是您包含了具有get_string声明的cs50.h,但是您没有包含具有其定义的库。要修复此问题,请在命令行上传递-lcs50。
https://stackoverflow.com/questions/57949078
复制相似问题