Skip to main content

Thread: Building my first kernel module, not going so well


i'm reading this book on programming kernel modules, , i've managed trip , fall on first example. source super-duper simple:

code:
/*   * hello-1.c - simplest kernel module.   */  #include <linux/module.h>  #include <linux/kernel.h>    int init_module( void )  {    printk( kern_info "hello world 1.\n" );      /*     * 0 return means init_module failed; module can't loaded.     */    return 0;  }    void cleanup_module( void )  {    printk( kern_info, "goodbye world 1.\n" );  }
as makefile:

code:
obj-m += hello-1.o    all:  	make -c /lib/modules/$(shell uname -r)/build m=$(pwd) modules    clean:  	make -c /lib/modules/$(shell uname -r)/build m=$(pwd) clean
and yet, when try compile on natty, headers installed, get:

code:
user@ubuntu:~/documents/kernel-modules$ make  make -c /lib/modules/2.6.38-8-generic/build m=/home/user/documents/kernel-modules modules  make[1]: entering directory `/usr/src/linux-headers-2.6.38-8-generic'  /usr/src/linux-headers-2.6.38-8-generic/arch/x86/makefile:81: stack protector enabled no compiler support    cc [m]  /home/user/documents/kernel-modules/hello-1.o  cc1: error: unrecognized command line option "-mregparm=3"  /home/user/documents/kernel-modules/hello-1.c:1: error: bad value (i686) -march= switch  assembler messages:  error: unknown architecture `i686'    error: unrecognized option -march=i686  make[2]: *** [/home/user/documents/kernel-modules/hello-1.o] error 1  make[1]: *** [_module_/home/user/documents/kernel-modules] error 2  make[1]: leaving directory `/usr/src/linux-headers-2.6.38-8-generic'  make: *** [all] error 2
anyways, before dive kbuild , try figure out what's going on, there can give me hint should doing here diagnose this? seems odd complains gcc has no support stack protectors - i'm using 4.5.2 imagine late enough this. , -march , -mregparms errors have me stumped.

works me™, make sure have build-essential installed, not gcc.


Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help [SOLVED] Building my first kernel module, not going so well


Ubuntu

Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support