Social Icons

Sunday, September 29, 2013



If you want to learn the Linux kernel source code its very much important that you understand the GNU/C compiler called the GCC. We will be using this compiler throughout the course. I will be using this GCC compiler to compile the programs in Linux. The reason why I am using this particular compiler is because this compiler is specifically used to compile the kernel source code. The Linux kernel is simply the source code which is in the c-syntax. All the source code is arranged into a set of .c files. If you want to compile this source code the compiler you ned to pick up is GCC.


The source code of Linux kernel is specific to the gcc i.e we cannot use any other compiler other than the gcc compiler which is also called the GNU/C compiler developed during the GNU project. Although the Linux kernel source code is  c-syntax, the reason why require specifically the gcc compiler is because the source code of Linux is not completely ANSI-C. Linux source code is gcc extensions. So, there is no other way than using the gcc compiler as long as you are using the Linux kernel source code.

                                                            Most of the developers also prefer the gcc compiler. Now days what's happening in the open-source especially with regard to the embedded systems and desktop applications is that almost all the distributions are combing the Linux kernel source code along with the core applications and releasing there own distribution. The distributors will download the Linux kernel source code and compile it using the gcc compiler and acquire the open-source packages and compile them and integrate them into one system. What I mean by open source packages are the core applications like gcc compiler, Libre office, LibreOffice Impress, LibreOffice Writer, LibreOffice calc etc. All these are open-source independent packages or open-source projects. You can find LibreOffice, LIbreOffice Impress etc  on the launcher bar in Ubuntu.

These icons are LibreOffice Writer, Calc, Impress. As Linux kernel source code is free open-source even these softwares are free open source projects. Now the distributor have to simply download the source code and these packages and compile them and integrate it to one system.
   It means a distribution is a KERNEL  + CORE APPLICATION SET.

Almost of all the open-source implementations of applications which uses c-syntax or c++ syntax  uses gcc and g++ compilers to compile the source code. So, whenever we download an open-source framework the only way to compile it is using the gcc or g++ compiler.

                                                 The gcc is the only tool chain that had been very widely used throughout the world. Gcc has the ability to compile C, Objective-C, Fortran, and also contains added libraries to compile the C++ source code as well. Hence I will be using this compiler tool chain to compile the programs and explain the concepts of kernel programming.

Any compiler distribution, when I say distribution its a set of tools we use to compile, debug, test, execute and verify an application. As a programmer what we require first is an interface to type and edit our programs, second we need a tool to compile or translate the program from any high level language to machine code, and third we require a method to test or execute and validate the application or program we wrote. Providing all these tools as a part of the framework is what we call as a distribution. In Windows terminology and most of the Windows developer community we call this as a Development Kit. So, when we say distribution it is synonymous to the development kits in Windows.


There are particularly two ways to use the compiler distribution.

You can have a GUI interface, an IDE(integrated development environment) is always a method of integrating all these tools into one application and use these tools through an IDE's  GUI interface.
IDE is like TURBO-C , ECLIPSE, FRAMA-C etc.. IDE's can simply speed up the process as there are many shortcuts we can use for debugging, compilation, execution and editing.

The other way is you can always use a command to invoke these tools, i.e invoke them through the command line. We don't require a unique IDE for this. So, Gcc can be used through an IDE or through and also can be used through the command line. If we need to access any tool we need to command it to access it.

                                                 When ever you are learning a new tool I advise you to always prefer to use a command to access it because IDE's often hide all this process. Proprietary tools like TURBO-C will hide the entire process where as in Linux you can view the entire process and learn more about it. There will be alot of flags and different implementations of a single tool which you cannot know if you are using an IDE. An other problem with using an IDE is that when you use an IDE persistently to compile programs and other purposes you get bound to that particular IDE, you become specific to that IDE and it becomes difficult for  you to switch to another IDE or any different environment. If you are using a command line to access it, there is always more scope that you will learn more about the use of a particular tool. So, initially I will be using Gcc on the command line to compile the programs. Our objective is to learn as much as we can. Once you are good with the command line you can always shift to an IDE. IDE is only an option. Its to speed up the process but if you want to learn its always recommended you use command line.

   Linux kernel source-code is completely c-syntax. There have always been speculation about why it is not C++. C++ is all about object orientation and Linux kernel is completely 100% object oriented. We do not need an object oriented syntax to implement object orientation and Linux source code is one of the best examples for C-syntax with complete object orientation. 0

No comments:

Post a Comment