For an academic project, I’m looking to add a source file (myfile.c) to the kernel/ directory, the same directory as exit.c and fork.c. The build system does not appear to automatically pick up the new file, as I’m hitting “undefined reference” link errors to functions defined in myfile.c. How could I get this file incorporated?
For an academic project, I’m looking to add a source file (myfile.c) to the
Share
You need to add a corresponding object file to the
kernel/Makefile. If you have a configuration variable for your code, then you would use:If you’re building in your code without a configuration variable, then you’ll just add it to the
obj-yvariable:The configuration variable expands to
y,m, orn, depending if the feature is built-in, built as a module, or turned off. Then theobj-y,obj-m, variables are built.