LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   The errors of "The hello world module" (https://www.linuxquestions.org/questions/linux-kernel-70/the-errors-of-the-hello-world-module-800349/)

shuge_guet 04-06-2010 09:12 AM

The errors of "The hello world module"
 
Hey all!I am a newer.I have many questiones when leaning module.
My code:

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

MODULE_LICENSE("Dual BSD/GPL")

static int hello_init(void)
{
printk(KERN_ALERT"Hello World enter\n");
return 0;
}

static void hello_exit(void)
{
printk(KERN_ALERT"Goodbye, cruel world\n");
}

module_init(hello_init);
module_exit(hello_exit);

MODULE_AUTHOR("Shuge");
MODULE_DESCRIPTION("A simple Hello World Module");
MODULE_ALIAS("A simplest module");



make -C /opt/Shuge_Linux/arm/linux-2.6.22.6 M=/opt/Shuge_Linux/Nfs_Linux/devices/Hello_Word modules
make[1]: Entering directory `/opt/Shuge_Linux/arm/linux-2.6.22.6'
CC [M] /opt/Shuge_Linux/Nfs_Linux/devices/Hello_Word/hello.o
In file included from include/asm/system.h:6,
from include/asm/bitops.h:23,
from include/linux/bitops.h:9,
from include/linux/thread_info.h:20,
from include/linux/preempt.h:9,
from include/linux/spinlock.h:49,
from include/linux/module.h:9,
from /opt/Shuge_Linux/Nfs_Linux/devices/Hello_Word/hello.c:2:
include/asm/memory.h:27:29: asm/arch/memory.h: No such file or directory
In file included from include/asm/system.h:6,
from include/asm/bitops.h:23,
from include/linux/bitops.h:9,
from include/linux/thread_info.h:20,
from include/linux/preempt.h:9,
from include/linux/spinlock.h:49,
from include/linux/module.h:9,
from /opt/Shuge_Linux/Nfs_Linux/devices/Hello_Word/hello.c:2:
include/asm/memory.h: In function `virt_to_phys':
include/asm/memory.h:170: error: `PHYS_OFFSET' undeclared (first use in this function)
include/asm/memory.h:170: error: (Each undeclared identifier is reported only once
include/asm/memory.h:170: error: for each function it appears in.)
include/asm/memory.h: In function `phys_to_virt':
include/asm/memory.h:175: error: `PHYS_OFFSET' undeclared (first use in this function)
include/asm/memory.h: In function `virt_to_bus':
include/asm/memory.h:193: warning: implicit declaration of function `__virt_to_bus'
include/asm/memory.h: In function `bus_to_virt':
include/asm/memory.h:198: warning: implicit declaration of function `__bus_to_virt'
In file included from include/linux/timex.h:187,
from include/linux/jiffies.h:8,
from include/linux/ktime.h:25,
from include/linux/timer.h:5,
from include/linux/workqueue.h:8,
from include/linux/slub_def.h:11,
from include/linux/slab.h:121,
from include/linux/percpu.h:5,
from include/asm-generic/local.h:4,
from include/asm/local.h:1,
from include/linux/module.h:19,
from /opt/Shuge_Linux/Nfs_Linux/devices/Hello_Word/hello.c:2:
include/asm/timex.h:15:28: asm/arch/timex.h: No such file or directory
In file included from include/linux/ktime.h:25,
from include/linux/timer.h:5,
from include/linux/workqueue.h:8,
from include/linux/slub_def.h:11,
from include/linux/slab.h:121,
from include/linux/percpu.h:5,
from include/asm-generic/local.h:4,
from include/asm/local.h:1,
from include/linux/module.h:19,
from /opt/Shuge_Linux/Nfs_Linux/devices/Hello_Word/hello.c:2:
include/linux/jiffies.h:225:31: warning: "CLOCK_TICK_RATE" is not defined
include/linux/jiffies.h:225:31: warning: "CLOCK_TICK_RATE" is not defined
include/linux/jiffies.h:225:31: division by zero in #if
include/linux/jiffies.h:225:31: warning: "CLOCK_TICK_RATE" is not defined
include/linux/jiffies.h:225:31: warning: "CLOCK_TICK_RATE" is not defined
include/linux/jiffies.h:225:31: division by zero in #if
include/linux/jiffies.h:225:31: warning: "CLOCK_TICK_RATE" is not defined
include/linux/jiffies.h:225:31: warning: "CLOCK_TICK_RATE" is not defined
include/linux/jiffies.h:225:31: division by zero in #if
include/linux/jiffies.h:225:31: division by zero in #if
include/linux/jiffies.h:225:31: warning: "CLOCK_TICK_RATE" is not defined
include/linux/jiffies.h:225:31: warning: "CLOCK_TICK_RATE" is not defined
include/linux/jiffies.h:225:31: division by zero in #if
include/linux/jiffies.h:225:31: warning: "CLOCK_TICK_RATE" is not defined
include/linux/jiffies.h:225:31: warning: "CLOCK_TICK_RATE" is not defined
include/linux/jiffies.h:225:31: division by zero in #if
include/linux/jiffies.h:225:31: warning: "CLOCK_TICK_RATE" is not defined
include/linux/jiffies.h:225:31: warning: "CLOCK_TICK_RATE" is not defined
include/linux/jiffies.h:225:31: division by zero in #if
include/linux/jiffies.h:225:31: division by zero in #if
include/linux/jiffies.h:225:31: warning: "CLOCK_TICK_RATE" is not defined
include/linux/jiffies.h:225:31: warning: "CLOCK_TICK_RATE" is not defined
include/linux/jiffies.h:225:31: division by zero in #if
include/linux/jiffies.h:225:31: warning: "CLOCK_TICK_RATE" is not defined
include/linux/jiffies.h:225:31: warning: "CLOCK_TICK_RATE" is not defined
include/linux/jiffies.h:225:31: division by zero in #if
include/linux/jiffies.h:225:31: warning: "CLOCK_TICK_RATE" is not defined
include/linux/jiffies.h:225:31: warning: "CLOCK_TICK_RATE" is not defined
include/linux/jiffies.h:225:31: division by zero in #if
include/linux/jiffies.h:225:31: warning: "CLOCK_TICK_RATE" is not defined
include/linux/jiffies.h:225:31: warning: "CLOCK_TICK_RATE" is not defined
include/linux/jiffies.h:225:31: division by zero in #if
include/linux/jiffies.h:225:31: warning: "CLOCK_TICK_RATE" is not defined
include/linux/jiffies.h:225:31: warning: "CLOCK_TICK_RATE" is not defined
include/linux/jiffies.h:225:31: division by zero in #if
include/linux/jiffies.h:225:31: warning: "CLOCK_TICK_RATE" is not defined
include/linux/jiffies.h:225:31: warning: "CLOCK_TICK_RATE" is not defined
include/linux/jiffies.h:225:31: division by zero in #if
include/linux/jiffies.h:225:31: division by zero in #if
In file included from include/asm/hardirq.h:6,
from include/linux/hardirq.h:7,
from include/asm-generic/local.h:5,
from include/asm/local.h:1,
from include/linux/module.h:19,
from /opt/Shuge_Linux/Nfs_Linux/devices/Hello_Word/hello.c:2:
include/asm/irq.h:4:27: asm/arch/irqs.h: No such file or directory
/opt/Shuge_Linux/Nfs_Linux/devices/Hello_Word/hello.c: At top level:
/opt/Shuge_Linux/Nfs_Linux/devices/Hello_Word/hello.c:6: error: syntax error before "static"
/opt/Shuge_Linux/Nfs_Linux/devices/Hello_Word/hello.c: In function `__inittest':
/opt/Shuge_Linux/Nfs_Linux/devices/Hello_Word/hello.c:17: error: `hello_init' undeclared (first use in this function)
make[2]: *** [/opt/Shuge_Linux/Nfs_Linux/devices/Hello_Word/hello.o] error 1
make[1]: *** [_module_/opt/Shuge_Linux/Nfs_Linux/devices/Hello_Word] error 2
make[1]: Leaving directory `/opt/Shuge_Linux/arm/linux-2.6.22.6'
make: *** [modules] error 2

pixellany 04-06-2010 09:21 AM

What is your question?

Hint: track down the first reported error before worrying about the rest:
Quote:

from /opt/Shuge_Linux/Nfs_Linux/devices/Hello_Word/hello.c:2:
include/asm/memory.h:27:29: asm/arch/memory.h: No such file or directory
How is hello.c relevant?
Find the memory.h file

shuge_guet 04-06-2010 10:13 AM

Thanks!


All times are GMT -5. The time now is 04:05 PM.