Re: really newbie: compiling a module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 29 Jul 2009, Siddu wrote:

> On Wed, Jul 29, 2009 at 7:31 PM, Mulyadi Santosa <mulyadi.santosa@xxxxxxxxx>
> wrote:
>       On Wed, Jul 29, 2009 at 8:55 PM, Gergely Buday<gbuday@xxxxxxxxx>
>       wrote:
>       > Dear kernel experts,
>       >
>       > I try to compile a module from Linux Device Drivers, 3rd
>       edition:
>       >
>       > ---
>       > #include <linux/init.h>
>       > #include <linux/module.h>
>       > MODULE_LICENSE("Dual BSD/GPL");
>       >
>       > static int hello_init(void)
>       > {
>       >    printk(KERN_ALERT "Hello, world\n");
>       >    return 0;
>       > }
>       >
>       > static void hello_exit(void)
>       > {
>       >    printk(KERN_ALERT "Goodbye, cruel world\n");
>       > }
>       >
>       > module_init(hello_init);
>       > module_exit(hello_exit);
>       > ---
>       >
>       > I got a makefile from
>       >
>       > http://www.tldp.org/LDP/lkmpg/2.6/html/x181.html
>       >
>       > namely
>       >
>       > obj-m += helloworld.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
>       >
>       > but that does not work on my system. What makefile should I
>       use and
>       > where should I put my helloworld.c?
>
>  
>       what error messages did you see?
>
> Please read all the articles by robert meant for newbie here . That should
> be able to answer your question 
> http://linux.com/search/kernel%2Bnewbie%2Bcorner/%252F?ordering=oldest&sear
> chphrase=exact&limit=20 

  thanks, i appreciate the recommendation.  from a quick glance, it
looks like the original poster hasn't installed the kernel-headers
package on his system.

  an easy way to tell is to check the current kernel version with:

$ uname -r

then make sure that, under the directory /lib/modules/<version>,
there is a symbolic link called "build" which takes you to the actual
kernel headers directory.  if that symlink isn't there, i don't think
you've installed the kernel headers, and that would definitely explain
your problems.

rday
--

========================================================================
Robert P. J. Day                               Waterloo, Ontario, CANADA

        Linux Consulting, Training and Annoying Kernel Pedantry.

Web page:                                          http://crashcourse.ca
Twitter:                                       http://twitter.com/rpjday
"Kernel Newbie Corner" column @ linux.com:          http://cli.gs/WG6WYX
========================================================================

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux