【发布时间】:2018-11-26 00:32:22
【问题描述】:
我的 XV6 中有三个文件:testmain.c、foo.h 和 foo.c:
foo.h:
extern void myfunction(void)
foo.c:
#include "foo.h"
void myfunction(void){
printf(1, "HelloWorld"); }
testmain.c:
#include "foo.h"
int main(void){
myfunction();
return 0 ; }
我在 test_main 中收到 myfunction() 未定义的引用错误。我知道我需要为 XV6 更改 Makefile 中的某些内容,但我不知道是什么。这就是我在 XV6 Makefile 中所做的更改:
UPROGS=\
_cat\
_echo\
_forktest\
_grep\
_init\
_kill\
_ln\
_ls\
_mkdir\
_rm\
_sh\
_stressfs\
_usertests\
_wc\
_zombie\
_foo\
_testmain\
【问题讨论】:
-
向我们展示整个makefile,以及makefile生成了哪些编译和链接命令。还有,foo.c 和 testmain.c 是不是在同一个目录下?
-
@Leonard github.com/jeffallen/xv6/blob/master/Makefile 是 XV6 制作文件。但是,如上所述,我更改了 UPROGS。这是编译错误:未定义对 'foo' 的引用 - 是的,它们在同一个目录中
-
好吧,我没有运行 XV6,所以我无法对此进行测试,但请尝试将 foo.o 添加到顶部的 OBJ 列表中。