Re: help needed- compilation issue

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

 



Thanks mr Rodrigues

with the make file you have provided the previous error was gone 

but gave a new error
error message ==================
cc     hello-1.c   -o hello-1
hello-1.c: In function ‘cleanup_module’:
hello-1.c:16: error: ‘KERN_ALERT’ undeclared (first use in this
function)
hello-1.c:16: error: (Each undeclared identifier is reported only once
hello-1.c:16: error: for each function it appears in.)
hello-1.c:16: error: syntax error before string constant
make: *** [hello-1] Error 1

end of error message =============

file =================

#include <linux/module.h>
#include <linux/kernel.h>

int module_init(void)
{
   printk("<1> Hello World 1. \n");

  // a non zero return means loaded failed ; module can't be loaded

   return 0;

}

void cleanup_module(void)
{
 printk(KERN_ALERT "Goodbye world 1, \n");
}
end of file ========================

Based on above error message when i replace  KERN_ALERT TO <1> .
try to compile ,
Iam getting a different error message.

error message=======================

make hello-1
cc     hello-1.c   -o hello-1
/usr/lib/gcc/i386-redhat-linux/4.0.2/../../../crt1.o(.text+0x18): In
function `_start':
: undefined reference to `main'
/tmp/cc0SuMYZ.o(.text+0xf): In function `module_init':
hello-1.c: undefined reference to `printk'
/tmp/cc0SuMYZ.o(.text+0x2c): In function `cleanup_module':
hello-1.c: undefined reference to `printk'
collect2: ld returned 1 exit status
make: *** [hello-1] Error 1

end error message ================= 

I have no clue what to do .
regards
Gowri





On Tue, 2006-02-21 at 13:44 +0900, Goldwyn Rodrigues wrote:
> On 2/21/06, Gowri Satish Adimulam <gowri@xxxxxxxxxxx> wrote:
> > Thanks every body ,
> > Now the make problem has been solved but a new problem has been emerged
> >
> >
> > gcc -c -O2 -DMODULE -D__KERNEL__  -W -Wall -Wstrict-prototypes
> > -Wmissing-prototypes -isystem /lib/modules/'uname -r'/build/include   -c
> > -o hello-1.o hello-1.c
> > In file included from /usr/include/linux/module.h:10,
> >                  from hello-1.c:1:
> > /usr/include/linux/config.h:5:2: error: #error Incorrectly using glibc
> > headers for a kernel module
> > hello-1.c: In function 'module_init':
> > hello-1.c:6: warning: implicit declaration of function 'printk'
> > hello-1.c: At top level:
> > hello-1.c:15: warning: no previous prototype for 'cleanup_module'
> > hello-1.c: In function 'cleanup_module':
> > hello-1.c:16: error: 'KERN_ALERT' undeclared (first use in this
> > function)
> > hello-1.c:16: error: (Each undeclared identifier is reported only once
> > hello-1.c:16: error: for each function it appears in.)
> > hello-1.c:16: error: syntax error before string constant
> > make: *** [hello-1.o] Error 1
> >
> > i tried to search in google but could get the exact solution
> >
> > Iam using FC4 , kernel 2.6.11-1.1369_FC4.
> >
> 
> Try this as the makefile contents:
> 
> 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
> 
> 
> 
> As Arjan said, your Makefile is broken. The one I hacve picked is from
> the latest LKMPG. I think you are compiling it according to the 2.4
> LKMPG.
> 
> 
> --
> Goldwyn


--
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