Re: kernel module compilation error

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

 



Hi Panthini,

You are trying to build executable instead of module, so you are
getting error about main function. Modules are object files they are
not executable.

Read module building from ->

1. writing Linux device drivers - rubini
    (http://lwn.net/Kernel/LDD3/) 3rd edition is for 2.6 kernel
    (http://www.xml.com/ldd/chapter/book/) 2nd edition is for 2.4 kernel
2. Linux kernel Module Programming Guide
    (http://www.tldp.org/LDP/lkmpg/2.6/html/index.html) 2.6 kernel
    (http://www.tldp.org/LDP/lkmpg/2.4/html/index.html) 2.4 Kernel

Regards,
Ameya.

On 9/23/05, Panthini <panthini.pandit@xxxxxxxxxxxxxx> wrote:
> Hi All,
> I am new to linux.
> I have written a small kernel module, which is having only 'printk' in
> init_module and cleanup_module.
> Configuration: RHEL 3- Linux kernel 2.4.21-27.EL
> snippet:
> /*************************************/
>         #include <linux/kernel.h>
>         #include <linux/module.h>
>         int init_module()
>        {
>            printk("<1>Hello\n");
>            return 0;
>        }
>         void cleanup_module()
>       {
>           printk("<1>bye\n");
>       }
> /**************************************/
> Following is the screenshot of compilation process:
>        [root@localhost root]# gcc -Wall -O2 -D__KERNEL__ -DMODULE
> -I/usr/src/linux-2.4.21-27.EL/include/ hello.c
>
> /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/../../../crt1.o(.text+0x18):
> In         function `_start':
>       : undefined reference to `main'
>        collect2: ld returned 1 exit status
>        [root@localhost root]#
> /***************************************/
> why this is referring to 'main' even though I have not written any
> main() function in hello.c.
> I could not figure out the problem.
>
> I will be thankful for your valuable suggestions.
>
> Thanks,
> Panthini
>
>
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/
>
>

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[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