在 xv6 中,我在内核文件夹中有
hello.h
,在用户文件夹中有 main.c
。
错误在main.c
。
内核/hello.h:
void hello();
内核/hello.c:
void hello(){
printf("hello\n);
}
现在我想调用函数
hello()
。但出现错误。
用户/main.c:
#include "kernel/types.h"
#include "kernel/stat.h"
#include "user/user.h"
#include "kernel/hello.h"
int main(int argc, char *argv[]) {
hello(); // error here (undefined reference to `hello')
exit(0);
}
您需要编译
hello.c
和 main.c
文件 和 将它们链接在一起。
gcc -o myprog main.c hello.c
./myprog