Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Open Source > Linux
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 12th, 2006, 11:07 PM
Registered User
 
Join Date: Oct 2006
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
 
Old October 24th, 2006, 07:49 AM
Friend of Wrox
 
Join Date: Dec 2003
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





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 05:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.