我对编程并不陌生,但我也远非专家。我正在从哈佛在线获取 CS50,我正在尝试使用 cs50 库中的函数,这些函数应该在 cs50 设备(Fedora 虚拟机版本 19-2)内自动工作。我的问题是,当我#include <cs50.h>
像他在讲座中那样编译时,我收到一条错误消息。
这是一个来自演讲幻灯片的简单程序。
#include <cs50.h>
#include <stdio.h>
int main(void)
{
// ask user for input
printf("Give me an integer: ");
int x = GetInt();
printf("Give me another integer: ");
int y = GetInt();
// do the math
printf("The sum of %i and %i is %i!\n", x, y, x + y);
}
这是我收到的错误消息:
jharvard@appliance (~/Dropbox/pset-1): ls
adder.c even-odd.c hello
jharvard@appliance (~/Dropbox/pset-1): clang -o adder adder.c
/tmp/adder-iuV3am.o: In function `main':
adder.c:(.text+0x19): undefined reference to `GetInt'
adder.c:(.text+0x32): undefined reference to `GetInt'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
jharvard@appliance (~/Dropbox/pset-1):
我的猜测是由于某种原因它没有找到图书馆。有没有人知道需要做什么才能让所有事情都说清楚?
我搜索了其他一些关于使用 cs50.c 文件的答案的问题,但我认为这些问题来自试图在他们自己的机器上而不是在一体机中编译的人。