LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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
  Search this Thread
Old 01-28-2009, 06:50 PM   #1
marcintom
LQ Newbie
 
Registered: Jan 2009
Posts: 1

Rep: Reputation: 0
Kernel module compilation problem


Hi
I want to compiling my own kernel loadable module.

I have one big module 2.6.18 kernel mod.c
I want to divide this to several files.
The problem is to write right Makefile

Code:
lib1.h
lib1.c

mod.c
mod.c works fine normally but when I divide into several files
and try to compile with this makefile

Code:
obj-m := mod.o
mod-objs := lib1.o

KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)

default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
I get this

Code:
zet modulANDlibs # make
make -C /lib/modules/2.6.18-gentoo-r2/build SUBDIRS=/root/modulANDlibs modules
make[1]: Entering directory `/usr/src/linux-2.6.18-gentoo-r2'
CC [M] /root/modulANDlibs/lib1.o
LD [M] /root/modulANDlibs/mod.o
Building modules, stage 2.
MODPOST
CC /root/modulANDlibs/mod.mod.o
LD [M] /root/modulANDlibs/mod.ko
make[1]: Leaving directory `/usr/src/linux-2.6.18-gentoo-r2'
zet modulANDlibs #
so this is ok but when I load this module there are no any operation
this mean mod.ko is loaded but dont work - before dividing it print to KERN_INFO "Hello world" ( dmesg )

There is one more thing. When I compile mod.c without lib* mod.ko have about 5.5Kb
but if I compile with mod-objs variable doesnt matter what is in mod.c and in lib1.c
compilation is ok loading is ok and size mod.ko is about 1.6 Kb constatntly

The questin is WHY ?
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
hello friends there is problem in linux kernel module compilation. kapilaryan2003 Mandriva 1 06-10-2008 08:07 AM
module compilation in kernel hovnatan Ubuntu 0 02-10-2007 04:33 AM
Kernel module with multiple source files compilation problem Last Attacker Programming 7 05-06-2006 09:10 AM
Installing irda module - problem during kernel compilation hobz Linux - General 3 07-08-2004 01:34 PM
kernel module compilation zbrox Linux - Software 1 01-28-2004 03:31 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:22 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration