Altera_Forum
Honored Contributor
19 years agoHello world build error!
Hi all,
When build the hello_world.c, I encount a error, Is any one can help me out? the hello_world.c as follows:#include <linux/init.h># include <linux/module.h># include <linux/kernel.h>
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);
MODULE_LICENSE("Dual BSD/GPL"); and the problem as follows: $ nios2-linux-uclibc-gcc linux-2.6.x/drivers/misc/hello.c -o hello -elf2flt="-s 4000"
In file included from /opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/sys-include/linux/sched.h:16,
from /opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/sys-include/linux/module.h:9,
from linux-2.6.x/drivers/misc/hello.c:6:
/opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/sys-include/linux/signal.h:2:2: warning:# warning "You should include <signal.h>. This time I will do it for you."
In file included from /opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/sys-include/linux/sched.h:79,
from /opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/sys-include/linux/module.h:9,
from linux-2.6.x/drivers/misc/hello.c:6:
/opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/sys-include/linux/resource.h:2:2: warning:# warning "You should include <sys/resource.h>. This time I will do it for you."
In file included from /opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/sys-include/asm/cache.h:25,
from /opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/sys-include/linux/cache.h:5,
from /opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/sys-include/linux/module.h:10,
from linux-2.6.x/drivers/misc/hello.c:6:
/opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/sys-include/asm/nios.h:4:26: nios2_system.h: No such file or directory
In file included from linux-2.6.x/drivers/misc/hello.c:6:
/opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/sys-include/linux/module.h:41: error: field `attr' has incomplete type
/opt/nios2/lib/gcc/nios2-linux-uclibc/3.4.6/../../../../nios2-linux-uclibc/sys-include/linux/module.h:49: error: field `kobj' has incomplete type
linux-2.6.x/drivers/misc/hello.c: In function `hello_init':
linux-2.6.x/drivers/misc/hello.c:14: error: `KERN_ALERT' undeclared (first use in this function)
linux-2.6.x/drivers/misc/hello.c:14: error: (Each undeclared identifier is reported only once
linux-2.6.x/drivers/misc/hello.c:14: error: for each function it appears in.)
linux-2.6.x/drivers/misc/hello.c:14: error: syntax error before string constant
linux-2.6.x/drivers/misc/hello.c: In function `hello_exit':
linux-2.6.x/drivers/misc/hello.c:19: error: `KERN_ALERT' undeclared (first use in this function)
linux-2.6.x/drivers/misc/hello.c:19: error: syntax error before string constant It says the 'KERN_ALERT' was not declared, but what try 'make', it has no problem. Is that it need include other files in hello_world.c? How to build executable file for nios independent? I hope anyone can help me out? ths!