In xv6, I have hello.h inside kernel folder, main.c inside user folder.
The error is in main.c.
kernel/hello.h:
void hello();
kernel/hello.c:
void hello(){
printf("hello\n);
}
Now I want to call function hello(). But get error.
user/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);
}
You need to compile
hello.candmain.cfiles and link them together.