As I was reading through the various posts, I was surprised that that it took 9 posts before the solution became apparent!
'gcc' should NOT be used directly to compile kernel modules. Use the procedure at shown in the previous post, or alternatively create a Makefile that encompasses everything that is required to build the module. Here's an example:
Code:
obj-m += hello.o
all:
$(MAKE) -C /lib/modules/`uname -r`/build M=$(PWD) modules
clean:
$(MAKE) -C /lib/modules/`uname -r`/build M=$(PWD) clean
$(RM) Module.markers modules.order
P.S. It is always best to use the command 'uname -r' to derive the current kernel version, rather than hard-coding the value. If a new kernel is added later (or if a different version exists on another platform), and the kernel version number is hard-coded in many scripts and/or Makefiles, it would be a bitch to go back and edit those.
Bookmarks