I have this primer assignment that I have to run inside a Linux VM (Version 2.6), and I’m trying to take this file
test_module.c
/*
* test module.
*/
#include <linux/module.h>
#include <linux/config.h>
#include <linux/init.h>
MODULE_LICENSE("GPL");
static int __init initialization_routine(void) {
printk ("Hello, world!\n");
return 0;
}
static void __exit cleanup_routine(void) {
printk ("Unloading module!\n");
}
module_init(initialization_routine);
module_exit(cleanup_routine);
And then I should be able to use the make command on this make file
makefile
make:
obj-m += test_module.o
But it keeps giving me the error obj-m not found. I’ve looked online, and can’t seem to find anything. Is there something I must install in order to get the object module command? Is it something i have to do with gcc?
You’re using
obj-mas a command when it’s not, it shouldn’t be listed after a target as you’re doing.The easiest way to compile your module is to follow this guide, or in your case just copy their simple makefile which makes it quite convenient to build it;