domingo, 7 de maio de 2017

Error compiling example kernel module from lkmpg.pdf

So you are now creating your first kernel module and still the "thing" does not want you to be the next kernel hacker ?

Here's some of the errors you will see:

+++++++++++++++
 make
uname: extra operand ‘−r’
Try 'uname --help' for more information.
uname: extra operand ‘−r’
Try 'uname --help' for more information.
make: Nothing to be done for `all'.


[Answer]:  Stop being lazy and don't just copy/past the code from the pdf, write your own code! That is: make sure that on the Makefile you have a "-" minus sign and NOT a a dash "−"

+++++++++++++++
make: Nothing to be done for `all'.

 [Answer]:  Stop being lazy by the second time, there is a "TAB" before "make -C /lib/modules/$(shell uname -r)/build M=$(shell pwd) modules" and not spaces, make is pick on this...

+++++++++++++++
make[2]: *** No rule to make target `/home/r/kernel_module/hello.c', needed by `/home/r/kernel_module/hello.o'.  Stop.
make[1]: *** [_module_/home/r/kernel_module] Error 2
-- Make sure file is under hello.c because your object will be hello.o-----

[Answer]: Now you want your own name.... so please make sure .o in Makefile match .c names you are coding, that is if your file is mynewkernelmodule.c make sure on Makefile you have  "mynewkernelmodule.o"

 +++++++++++++++

Have fun!