LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 06-26-2006, 02:07 AM   #16
asprakash
Member
 
Registered: May 2006
Location: Chennai, India
Posts: 74
Blog Entries: 3

Rep: Reputation: 18
U can try with Makefile


Quote:
Originally Posted by m.anju
hi,
I m new to linux i am trying kernel programming while insertion of mod error comes when i tried the command

#gcc -c hello.c -o hello.o -isystem /usr/src/linux-2.4.20-8/include -D__KERNEL__ -DLINUX

error: couldn't find the kernel version the module was compiled for

then instead of -isystem i tried -I the problem is not yet solved

Thanx
U can compile u'r code by Makefile.
create a file name called "Makefile" (should be) in u'r code directory.
edit it as follows,

obj-m += hello.o //(u'r code filename.o)
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

No need to compile the Makefile. then enter the command "make" in the same directory. it will create .ko file, if u r using 2.6 kernel.otherwise, .o file. Once u compiled u'r code by "make", if u want to compiled it again, enter "make clean", then enter "make".

try it.
 
Old 06-26-2006, 04:41 AM   #17
shahneepa
LQ Newbie
 
Registered: Jun 2006
Posts: 2

Rep: Reputation: 0
Hi,

I trying to compile my kernel for Broadcom Netxterme 5782 with Broadcom Tigon3 (tg3) which is with linux but not compiled. so while compiling and making module by command:

make modules

It giving an error like:

make[2]:*** [tg3.o] Error1
make[2]: Leaving directory `/usr/src/Linux-2.4.20-8/drivers/net`
make[1]:*** [_modsubdir.net] Error 2
make[1]: Leaving directory `/usr/src/Linux-2.4.20-8/drivers`
make[1]:*** [_mod_drivers] Error 2


I don't understand this error message and if you have any otherway to activate Broadcom NIC please do write that also.

Thanks in advance.

Best,
Neepa.
 
Old 06-26-2006, 05:54 AM   #18
the_unforgiven
LQ Newbie
 
Registered: Apr 2006
Posts: 12

Rep: Reputation: 0
Quote:
Originally Posted by shahneepa
Hi,

I trying to compile my kernel for Broadcom Netxterme 5782 with Broadcom Tigon3 (tg3) which is with linux but not compiled. so while compiling and making module by command:

make modules

It giving an error like:

make[2]:*** [tg3.o] Error1
make[2]: Leaving directory `/usr/src/Linux-2.4.20-8/drivers/net`
make[1]:*** [_modsubdir.net] Error 2
make[1]: Leaving directory `/usr/src/Linux-2.4.20-8/drivers`
make[1]:*** [_mod_drivers] Error 2


I don't understand this error message and if you have any otherway to activate Broadcom NIC please do write that also.

Thanks in advance.

Best,
Neepa.
Do you have it enabled in your kernel config?
If yes, then from your top-level kernel source directory, just do make modules
If not, then configure your kernel as given in the README and then compile the modules.
 
Old 06-30-2006, 03:24 AM   #19
m.anju
LQ Newbie
 
Registered: Jun 2006
Posts: 7
Blog Entries: 2

Rep: Reputation: 0
Thanks asprakash its working, one more problem

i want to compile one file which is composed of two different files
i used the command but error of something missing is coming, could u plz suggest the possible reason

ld -m elf_i386 -r -o file.o file1.o file2.o

Thanks in advance
 
Old 06-30-2006, 04:54 AM   #20
x86processor
Member
 
Registered: Jun 2006
Location: Chennai, India
Distribution: Embdebian, Debian, Fedora Core, Redhat, Slackware, Ubuntu.
Posts: 112

Rep: Reputation: 15
Quote:
gcc -c hello.c -o hello.o -I /usr/src/linux-2.4.20-8/include -D__KERNEL__
You ate the other parameter options? (just kidding)

Use a proper Makefile to build drivers. Check in your kernel .config file if you have CONFIG_MODVERSIONS set.

Check my device driver examples for a simple driver and Makefile examples:
http://www.shakthimaan.com/downloads.html
 
Old 07-10-2006, 12:47 AM   #21
deep200412
LQ Newbie
 
Registered: Jul 2006
Posts: 5

Rep: Reputation: 0
No output

I compiled the hello_world module in 2.4.20 Kernel version. It was succesfull. I then loaded the module using insmod command. It was succesful ( lsmod command showed my module name ) But I got no output . I used the printk("hello world") function and used the module_init() function in the hello world program.

Can anyone tell me what's the problem ??
 
Old 07-11-2006, 12:17 AM   #22
asprakash
Member
 
Registered: May 2006
Location: Chennai, India
Posts: 74
Blog Entries: 3

Rep: Reputation: 18
Dear friend!
Please post your threads separately!
U should compile you module program from console only; Not from X window.Printk doesn't print anything on the screen, when you are using X window.so use "dmesg" to show the message; If you use console you can see your message without use of dmesg command.
 
  


Reply

Tags
modules



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
compiling modules in kernel 2.6 DrowningFish Programming 4 03-18-2006 05:03 AM
Compiling too many modules into kernel samac Slackware 13 02-27-2006 06:35 PM
Compiling kernel modules NNP Programming 4 12-18-2005 02:08 PM
need some help in Compiling Kernel modules bharat83 SUSE / openSUSE 1 01-07-2005 07:21 AM
Compiling kernel modules? jrjarrett Linux - Software 0 09-09-2003 10:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 07:03 AM.

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