Showing posts with label makefile. Show all posts
Showing posts with label makefile. Show all posts

Sunday, December 12, 2010

Compile Device Driver for Linux in Eclipse

There is an easy way to compile device driver in Linux using eclipse, once its been setup life becomes much easy, as you don't have to switch between the editor and the command shell every time you need to change something,

Here is the screen shot of my project, Look at it carefully, all you need to add to the project are main.c and a makefile. rest are the result of compilation. makefile will only contain one line obj-m := main.o


Most of the things remain same for the simple C project as mentioned in the previous post, after creating the project, you need to change the command to build the project as,

make -C /usr/src/linux-headers-2.6.35-22-generic M=$(PWD) modules

The path given above is my linux kernel header file path, change to yours accordingly. After this, you set the build directory to the directory of your source code for device drivers. And in the behavior tab, remove the all from build command line, other wise it will crib saying could not find rule to build all !! 

Thats it, you are ready to use the Eclipse IDE for device driver development, all the best !


Saturday, December 11, 2010

Compile C/C++ code in eclipse using makefiles

In Linux, usually compilation is done using makefiles, run in command shell. I use to work on Linux kernel, and in such cases, I use to setup a Samba server for editing and source code browsing was done in windows. But then now I am using only one PC, which is a dual boot for windows and Ubuntu Linux, so I cannot have samba server. I was looking for a IDE in Linux, and found eclipse to be very useful.

I wasn't very familiar with the eclipse IDE and I was trying to setup the compilation using makefiles, initially I had some hiccups but could later configure it easily after generating an example C project from it and following similar methods to write the makefiles.

Here is the method to do it, so it might come handy to you in case if you are trying to use eclipse IDE for compiling C/C++ project using make files.

First create a empty C/C++ project, makefile project, and select the --other tool chain--. keep the project settings to default, as shown in the below figure. Click finish.


Once project is created, as a C file, and a 'makefile'. The makefile tells the make program about how the project should be built, I am giving here the sample make file for the simple HelloWorld.c, which you can further extend as per your use.