0

I met error pintos/src/userprog/build/../../userprog/syscall.c:56: undefined reference to `exit' while working on a pintos project.

Below is part of directory tree that is related with error.

-lib
    -user
        -syscall.c
        -syscall.h
           
-userprog
    -syscall.c

(lib and userprog have same hierarchy.)

In userprog/syscall.c, The function exit is well-defined on both header file and c file.

// lib/user/syscall.c
void
exit (int status)
{
  syscall1 (SYS_EXIT, status);
  NOT_REACHED ();
}
// lib/user/syscall.h

void exit (int status) NO_RETURN;

But When I call exit on userprog/syscall.c, I meet error undefined refrence to 'exit' I includede syscall.h in lib/user/ as #include "lib/user/syscall.h"

// userprog/syscall.c

#include "lib/user/syscall.h"
void
foo()
{
   ...
   exit(-1); 
}

What would be the problem?

  • Does this answer your question? [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Raildex Sep 25 '22 at 11:41
  • You have two source files named syscall.c. Non-zero odds that this confuses the dickens out of the toolchain with one object file overwriting the other. Pick another name for the userprog file and ensure you link both. – Hans Passant Sep 25 '22 at 12:26
  • Post the command line you use to build the project. – user58697 Sep 26 '22 at 00:08
  • Linker might not find `lib/user/syscall.o`, check your `Makefile`. – S Dao Sep 26 '22 at 06:18

0 Answers0