Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Open Source > Linux
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Linux General discussion of programming the various flavors of Linux operating systems.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Linux section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 12th, 2006, 11:07 PM
Registered User
 
Join Date: Oct 2006
Location: Bangalore, Karanataka, India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to shyjumon.n
Default Kernel compilation probelm

Hi, new here, and having trouble with hello-1.c compliling.
I am using Fedora Core 4, and here is my hello-1.c
/*
 * hello#8722;1.c #8722; The simplest kernel module
 */
#define KERN_INFO
        module_LICENSE("GPL"); //also tried MODULE_LINCENSE("GPL");

#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */
int init_module(void)
{
        printk(KERN_INFO "Hello world 1.\n");
        /*
         * A non 0 return means init_module failed; module can't be loaded.
         */
        return 0;
}
void cleanup_module(void)
{
        printk(KERN_INFO "Goodbye world 1.\n");
}
 here is my make file
CFLAGS = -D __KERNEL__ -D MODULE -isystem /lib/modules/`uname -r`/build/include/
$ hello-1.o: hello-1.c
        gcc $(CFLAGS) -O2 -Wall -c hello-1.c
.PHONY: clean
clean:
        rm -rf *.o a.out

gcc -D __KERNEL__ -D MODULE -isystem /lib/modules/`uname -r`/build/include/ -O2 -Wall -c hello-1.c
hello-1.c:5: error: syntax error before string constant
hello-1.c:5: warning: type defaults to ‘int’ in declaration of ‘module_LICENSE’
hello-1.c:5: warning: data definition has no type or storage class
In file included from /usr/include/linux/module.h:10,
                 from hello-1.c:7:
/usr/include/linux/config.h:5:2: error: #error Incorrectly using glibc headers for a kernel module
hello-1.c: In function ‘init_module’:
hello-1.c:11: warning: implicit declaration of function ‘printk’
make: *** [hello-1.o] Error 1

Here is the output from the screen.

Thanks for the help.


smn
Reply With Quote
  #2 (permalink)  
Old October 24th, 2006, 07:49 AM
Friend of Wrox
Points: 1,515, Level: 15
Points: 1,515, Level: 15 Points: 1,515, Level: 15 Points: 1,515, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2003
Location: Oxford, , United Kingdom.
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Code:
#define KERN_INFO
        module_LICENSE("GPL");
What happens if you put this all on to one line? i.e.

Code:
#define KERN_INFO module_LICENSE("GPL");
--
Don't Stand on your head - you'll get footprints in your hair
                                           http://charlieharvey.org.uk
                                              http://charlieharvey.com
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
linux kernel compilation problem abhishekshrivastav Linux 4 October 13th, 2006 06:47 AM
Kernel Hooks J-Rod Need help with your homework? 0 August 30th, 2006 02:21 AM
Building a kernel jwarburton Linux 2 January 23rd, 2005 04:44 PM



All times are GMT -4. The time now is 01:13 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.