Results 1 to 6 of 6
Hi
How do I compile c source code using gcc so that it would produce .ko objects for kernel module development? I'm trying to use Eclipse to manage development projects ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 09-28-2009 #1Just Joined!
- Join Date
- Jul 2008
- Posts
- 12
GCC and Kernel Development [compile help]
Hi
How do I compile c source code using gcc so that it would produce .ko objects for kernel module development? I'm trying to use Eclipse to manage development projects but can't use the build feature just yet since I don't know what to put in.
Thanks.
- 09-28-2009 #2
does eclipse even support a C IDE? if you want to do kernel development you will need to install the linux-headers and build-essential packages, I think it would be
if you are looking for how to do kernel module development, I would start here: Linux Device Drivers, Third Edition [LWN.net]Code:sudo apt-get install build-essential linux-headers-`uname -r`
- 09-29-2009 #3Just Joined!
- Join Date
- Jul 2008
- Posts
- 12
re
Eclipse has CDT (C/C++ Development Tools) and I've already done some C/C++ projects using it. I don't know how to set it up to automate the building of kernel modules from C source code. I usually do it by manually creating the Makefiles as stated in tutorials. If I can use the gcc command (with corresponding options) than I can set it up in Eclipse.
- 09-29-2009 #4
So you just need to know how to create a make file that will build a kernel module? You want to generate this makefile automatically or manually? The link in my previous post will show you how to create a make file that will compile a kernel module. If you need to automate this, you will need to look into using some kind of configure script, I'm sure there are many tutorials you can find on configure scripts by searching google.
- 09-29-2009 #5Just Joined!
- Join Date
- Jul 2008
- Posts
- 12
- 09-29-2009 #6Just Joined!
- Join Date
- Jul 2008
- Posts
- 12
I got the makefile working but I couldn't compile 2 or more source codes.
I have 2 files named nothing.c and hello.c
Here's my current makefile:
I wanted to produce a kernel module named test.ko but it produces this error:Code:obj-m := test.o module-objs := nothing.o hello.o default: make -C /lib/modules/`uname -r`/build M=`pwd` modules
make -C /lib/modules/`uname -r`/build M=`pwd` modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.28-15-generic'
make[2]: *** No rule to make target `/home/rba1988/Desktop/test.c', needed by `/home/rba1988/Desktop/test.o'. Stop.
make[1]: *** [_module_/home/rba1988/Desktop] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.28-15-generic'
make: *** [default] Error 2


Reply With Quote

