-1

我正在与 Nachos 一起做一个学校项目,我收到了一些奇怪的错误。你可以在这里看到我的代码:只是 c 文件,如果你需要更多,请让我知道

控制台的输出如下所示:

../gnu/gcc -G 0 -c -I../userprog -I../threads -I../machine -c threadtest.c
../gnu/ld -T newscript -N start.o threadtest.o -o threadtest.coff
threadtest.o: In function `CreateClerk':
threadtest.c:804: undefined reference to `memcpy'
threadtest.o: In function `ApplicationClerkNoCustomerAtRegister':
threadtest.c:902: undefined reference to `memcpy'
threadtest.c:902: undefined reference to `memcpy'
threadtest.c:902: undefined reference to `memcpy'
threadtest.o: In function `PictureClerkNoCustomerAtRegister':
threadtest.c:954: undefined reference to `memcpy'
threadtest.o:threadtest.c:954: more undefined references to `memcpy' follow
gmake: *** [threadtest] Error 1

在我的整个 Nachos 项目文件夹中,没有一次调用“memcpy”(我在文件搜索中使用括号进行了查找)。

这是第 804+ 行:

struct Clerk CreateClerk(char* _name, int _number, struct PassportOffice* _theOffice, struct Line* theLine) {
    struct Clerk theClerk;
    theClerk.name = _name;
    theClerk.number = _number;
    theClerk.theOffice = _theOffice;
    theClerk.myLine = theLine;
    LineSetClerk(theClerk.myLine,&theClerk);
    theClerk.dataLock = CreateLock("dataLock",8);
    theClerk.myBribeCV = CreateCV("myBribeCV",9);
    theClerk.breakCV = CreateCV("breakCV",7);
    theClerk.breakLock = CreateLock("breakLock",9);
    theClerk.walkUpCV = CreateCV("walkUpCV",8);
    return theClerk;
}
4

1 回答 1

2

您应该使用gccto 链接,而不是ld.

当您通过gcc它链接时,它会将系统库提供给ld. 如果您通过链接进行链接,ld则必须自己指定所有内容以及一堆其他内容。

于 2015-10-16T05:14:03.320 回答