Linux and C Programming "undefined reference to function"
Posted on 2004-09-05
I've been working on the linux kernel itself. Let' me describe the problem. It's kind of long-winded.
I have modified the open.c file by adding in the following lines
and at the beginning of this modified open.c file, I've added
Inside the audit-CHDIR.c file, we have the line
and inside the audit.h file, we have the line
int audit(audit_header*, void*);
All is well so far, until I compile the code. Apparently, compilation works fine because the audit function is declared in the audit.h header file. but an error occurred during the linking stage ( i assume this error message only occurs at linking stage)
fs/fs.o(.text+0x764): In function `sys_chdir':
: undefined reference to `audit'
The reason I can think of is that there is no way for the build system to know where audit function is DEFINED. The compiler knows that audit function is DECLARED in the audit.h file, but the linker has no idea that audit function is defined in /usr/src/linux/kernel/audit.c. And I don't know how to let the linker know about this.
Thanks for your help.