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.


Sign Up Now
Reply to this topicStart new topic
> Linux Kernel Newbie
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


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.

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


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

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


When I compile I get following errors

[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]#

Can someone help me with this problem ?

Following is my Kernel Version

[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]#

and my gcc version
[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]#
Go to the top of the page
+Quote Post
post Jun 13 2005, 06:26 AM
Post #2

Its GNU/

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:

        printk(KERN_ALERT "HELLO, WORLDn");

should be

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

Want to help out 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: 21st July 2018 - 03:44 PM