LinuxQuestions.org
Support LQ: Use code LQCO20 and save 20% on CrossOver Office
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 10-23-2009, 02:41 PM   #1
nayankumarp
LQ Newbie
 
Registered: May 2008
Posts: 5

Rep: Reputation: 0
loding Kernel module with multiple source files


Hi All
I have a problem in loading the kernel module that is multiple source file.
At this stage its a plain kernel module having init and exit and one function that is beeing called from init module for showing the version .
To have 1 file for my module it works fine but if I have multiple
source files it compiles but it gives tainted message and init function is not getting invoked at all while loading the module.

i have file1.c file2.c file1.h and Makefile

following is my makefile

ifneq ($(KERNELRELEASE),)
obj-m := file1.o
file1-objs := file1.o file2.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD :=$(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif

clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions

following is my file1.c
#include <linux/init.h>
#include <linux/module.h>

#include "file1.h"

MODULE_LICENSE("Dual BSD/GPL");

static int hello_init(void)
{
printk(KERN_ALERT "Hello world \n");
show_version();
return 0;
}

static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye, cruel world \n");
}

module_init(hello_init);
module_exit(hello_exit);

following is my file1.h
#ifndef _FILE1_H_
#define _FILEL1_H_

#define version "1.0"

void show_version(void);

#endif

following is my file2.c

#include <linux/kernel.h>
#include "file1.h"

void show_version(void)
{
printk(KERN_ALERT "Version is:%s \n",version);
}

Please help me in solving this problem any help will be greatly appreciated.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
linking multiple files kernel module programming charlotteix9 Programming 1 02-17-2009 01:28 PM
Kernel module with multiple source files compilation problem Last Attacker Programming 7 05-06-2006 10:10 AM
problems in loding e100 module during startup porous Linux - General 1 08-12-2005 09:55 AM
creating Makefile with multiple kernel module files b123coder Programming 0 12-26-2004 09:41 AM
Building kernel module from multiple source file in 2.6 kernel yogeshwar_s Programming 1 12-20-2004 10:31 AM


All times are GMT -5. The time now is 08:18 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration