Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
> Linux Kernel Newbie
nkhambal
post Jun 9 2005, 01:08 AM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 1
Joined: 9-June 05
Member No.: 5,098



Hi,

I just started learning Linux device driver programming. I have been trying to compile this "hello, world" program on Fedora Core 3. But I am unable to do so. Following is Code.

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

MODULE_LICENSE("Dual BSD/GPL");

static int hello_init(void)
{
       printk(KERN_ALERT "HELLO, WORLDn");
       return 0;
}

static void hello_exit(void)
{
       printk(KERN_ALERT "GOOD BYE, WORLDn");
}

module_init(hello_init);
module_exit(hello_exit);


When I compile I get following errors

[quote]
[root@devlinux snoopy]# gcc -c mod1.c
mod1.c: In function `hello_init':
mod1.c:9: error: `KERN_ALERT' undeclared (first use in this function)
mod1.c:9: error: (Each undeclared identifier is reported only once
mod1.c:9: error: for each function it appears in.)
mod1.c:9: error: syntax error before string constant
mod1.c: In function `hello_exit':
mod1.c:15: error: `KERN_ALERT' undeclared (first use in this function)
mod1.c:15: error: syntax error before string constant
[root@devlinux snoopy]#
[/quote]

Can someone help me with this problem ?

Following is my Kernel Version

[quote]
[root@devlinux snoopy]# uname -a
Linux devlinux 2.6.9-1.667 #1 Tue Nov 2 14:41:25 EST 2004 i686 i686 i386 GNU/Linux
[root@devlinux snoopy]#
[/quote]

and my gcc version
[quote]
[root@devlinux snoopy]# gcc -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
Thread model: posix
gcc version 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)
[root@devlinux snoopy]#
[/quote]
Go to the top of the page
 
+Quote Post
 
Start new topic
Replies (1 - 1)
Corey
post Jun 13 2005, 06:26 AM
Post #2


Its GNU/Linuxhelp.net
*******

Group: Admin
Posts: 1,254
Joined: 21-September 02
From: St John's, Newfoundland, Canada
Member No.: 3



I'm no programmer, but i've dabbled in C from time to time.

At first glance, i would guess you're missing a comma between your loglevel and message:

QUOTE
        printk(KERN_ALERT "HELLO, WORLDn");


should be

QUOTE
        printk(KERN_ALERT, "HELLO, WORLDn");


You'll want to fix both entires of this.

But, like i said, i'm no programmer, this is just a guess. I don't know how else the compiled would be able to tell the what's what without it smile.gif


--------------------
Corey Quilliam
(former) Linuxhelp.ca Administrator
cquilliam-AT-gmail-dot-com

Want to help out Linuxhelp.net? Check out our Linuxhelp Wiki and see if there are some articles you would like to submit!!

--
Ubuntu 8.04 64-bit - Work Laptop (HP-Compaq NC6400 Core2)
Kubuntu 8.04 64-bit - Desktop (HP m8120n QuadCore)
Ubuntu 6.04 - Server (I'm not upgrading this baby until support runs out in 2012) (Some old POS dell)
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 16th December 2017 - 11:59 AM