LinuxQuestions.org
Help answer threads with 0 replies.
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 07-24-2008, 02:15 AM   #1
hash123
LQ Newbie
 
Registered: Jul 2008
Posts: 11

Rep: Reputation: 0
Unhappy cant build .ko file from .c file


i am working on fedora core 8 installed as a guest OS on a vmware server

i am trying to generate a sample kernel object file called a .ko file from a .c file to print "hello world".
i have written a Makefile to compile the .c file and generate a .ko file.
both the files are as follows:

------------------------------------------------------
//hello.c

#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>


static int __init hello_init(void)
{
printk(KERN_ALERT "hello world!!!!!!\n");
return 0;
}

static void __exit hello_exit(void)
{
printk(KERN_ALERT "good bye!!!!!!\n");
}

module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("test module");
MODULE_AUTHOR("HASH123");

-----------------------------------------------------------

-------------------------------------------------------------
//Makefile

obj-m := hello.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

------------------------------------------------------------


now when i type the "make" command i get the following error:


make -C /lib/modules/2.6.23.1-42.fc8/build SUBDIRS=root/hash123/test modules
make: *** /lib/modules/2.6.23.1-42.fc8/build: no such file or directory. Stop.
make: *** [default] Error 2


can anybody tell me what is the problem and how to solve the problem?
 
Old 07-24-2008, 02:24 AM   #2
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 55
Quote:
make: *** /lib/modules/2.6.23.1-42.fc8/build: no such file or directory. Stop.
Does the directory exist?
 
Old 07-24-2008, 03:35 AM   #3
hash123
LQ Newbie
 
Registered: Jul 2008
Posts: 11

Original Poster
Rep: Reputation: 0
it exists as a link at the path /lib/modules/2.6.23.1-42.fc8/

it is a link to the directory /usr/src/kernels/2.6.23.1-42.fc8-i686/

but i checked that my /usr/src/ directory is empty.

so now what do i do?
 
Old 07-24-2008, 04:03 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
You have to install the kernel sources. Package is kernel-devel-2.6.23.1-42.fc8.i686.
 
Old 07-24-2008, 04:07 AM   #5
hash123
LQ Newbie
 
Registered: Jul 2008
Posts: 11

Original Poster
Rep: Reputation: 0
where do i get the package from and how do i install it?
also at what path should the package be kept to install it?

Last edited by hash123; 07-24-2008 at 04:13 AM.
 
Old 07-24-2008, 04:16 AM   #6
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 55
I asked Google: fedora core 8 packages install
The first hit seems useful:

http://www.fedorafaq.org/
 
Old 07-24-2008, 05:15 AM   #7
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
You can either use the graphical interface or the command line. Using the graphical interface is as simple as selcting "Add/Remove Software" from the "System -> Administration" menu. Using the command line is as simple as running the following command from a terminal:
Code:
yum install kernel-devel-2.6.23.1-42
Don't bother about the installation path: it is hardcoded in the package itself and all the files will be installed in the standard locations. Obviuosly - as you expect - the kernel source will be installed under /usr/src.
 
Old 07-24-2008, 05:51 AM   #8
hash123
LQ Newbie
 
Registered: Jul 2008
Posts: 11

Original Poster
Rep: Reputation: 0
i have successfully installed the required rpm and
now when type make at the commandline it gives the following error:

[root@dlhgn47dhcp157 test]# make
make -C /usr/src/kernels/2.6.23.1-42.fc8-i686/ SUBDIRS=/root/hash123/test modules
/usr/src/kernels/2.6.23.1-42.fc8-i686/scripts/gcc-version.sh: line 16: gcc: command not found
/usr/src/kernels/2.6.23.1-42.fc8-i686/scripts/gcc-version.sh: line 17: gcc: command not found
make[1]: gcc: Command not found
make[1]: Entering directory `/usr/src/kernels/2.6.23.1-42.fc8-i686'
CC [M] /root/hash123/test/hello.o
/bin/sh: gcc: command not found
make[2]: *** [/root/hash123/test/hello.o] Error 127
make[1]: *** [_module_/root/hash123/test] Error 2
make[1]: Leaving directory `/usr/src/kernels/2.6.23.1-42.fc8-i686'
make: *** [default] Error 2

Last edited by hash123; 07-24-2008 at 06:51 AM.
 
Old 07-24-2008, 06:07 AM   #9
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
You could try making the symbolic links manually with 'ln -s /usr/src/kernels/2.6.23.1-42.fc8-i686/ /lib/modules/2.6.23.1-42.fc8/build; ln -s /usr/src/kernels/2.6.23.1-42.fc8-i686/ /lib/modules/2.6.23.1-42.fc8/source' (but they *should* be there) or change your KDIR to read "KDIR := /usr/src/kernels/2.6.23.1-42.fc8-i686".
 
Old 07-24-2008, 06:44 AM   #10
hash123
LQ Newbie
 
Registered: Jul 2008
Posts: 11

Original Poster
Rep: Reputation: 0
the links already exist.It is not the problem with the links

the problem exists somewhere else
 
Old 07-24-2008, 06:58 AM   #11
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 55
Quote:
make[1]: gcc: Command not found
Do you have no compiler installed?
 
Old 07-24-2008, 07:18 AM   #12
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Right. No compiler installed.
 
Old 07-24-2008, 11:35 PM   #13
hash123
LQ Newbie
 
Registered: Jul 2008
Posts: 11

Original Poster
Rep: Reputation: 0
is there any other way to install the gcc compiler without using yum ?
 
Old 07-25-2008, 02:23 AM   #14
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 55
Why would you want to do that? (rhetorical question - sorry)
1.) you can install the .rpm directly - but is does have dependencies _you_ need to solve then
2.) you build your own compiler...mmh ...no - you need a compiler for this
You could use yum to install it temporarily - build your own - and deinstall the one installed by yum

Other than that - have a look at the documentation for LFS - maybe you find a way there.
http://www.linuxfromscratch.org/lfs/view/stable/
 
Old 07-25-2008, 03:25 AM   #15
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by hash123 View Post
is there any other way to install the gcc compiler without using yum ?
Use the graphical interface (as suggested above). From the Gnome Menu -> System -> Administration -> Add/Remove Software. yum from command line is the quicker method, anyway.
 
  


Reply



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
Need to build a file manager atripathy86 Programming 4 06-27-2006 11:44 AM
build rpm file . bruse Linux - Newbie 4 09-11-2005 10:06 AM
How to build a rpm file from the source file? Flamenco Mandriva 5 12-22-2004 03:40 AM
How to re-build a corrupted content file ? ]un]ie Solaris / OpenSolaris 0 09-06-2004 05:16 AM
Config File in build directory dwessell Mandriva 1 05-08-2004 07:39 PM

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

All times are GMT -5. The time now is 04:16 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