glugt-mgl

 

Programming

Page history last edited by vinod 2 yrs ago

 Programming  

 

 Basic Programming in Linux  

 

Most Linux distributions support dozens of programming languages. Core system software such as libraries and basic utilities are usually written in C. Enterprise software is often written in C, C++, Java, Perl, Ruby, or Python. The most common collection of utilities for building both Linux applications and operating system programs is found within the GNU toolchain, which includes the GNU Compiler Collection (GCC) and the GNU build system. Amongst others, GCC provides compilers for C, C++, Java, and Fortran. The Linux kernel itself is written to be compiled with GCC.

 

 

Most distributions also include support for Perl, Ruby, Python and other dynamic languages. Examples of languages that are less common, but still well-supported, are C# via the Mono project, and Scheme. A number of Java Virtual Machines and development kits run on Linux, including the original Sun Microsystems JVM (HotSpot), and IBM's J2SE RE, as well as many open-source projects like Kaffe. The two main frameworks for developing graphical applications are those of GNOME and KDE. These projects are based on the GTK+ and Qt widget toolkits, respectively, which can also be used independently of the larger framework. Both support a wide variety of languages. There are a number of Integrated development environments available including Anjuta, Eclipse, KDevelop, MonoDevelop, NetBeans, and Omnis Studio while the traditional editors Vim and Emacs remain popular.

Although free and open source compilers and tools are widely used under Linux, there are also proprietary solutions available from a range of companies, including the Intel C++ Compiler, PathScale, Micro Focus COBOL Franz Inc, and the Portland Group.

 

 

 

 Development Tools  

 

   * eclipse,anjuta,kdevelop,codeblocks - development enviroments

   * emacs,vim - highly sophisticated text editors suitable for programming/development

   * bluefish,screem - php/html/css editors

 

 

 

Programming in C/C++

 

 

Writing

 

Any code saved with an extension to .c(.cpp) can be a valid C/C++ program.

When you use a gedit editor

 

  

     Alt+F -> S  or simply Ctrl+S

     to save a given file(like in windows)

 

Compiling

 

The C compiler available in Linux is gcc (GNU Compiler Collection) and the C++ compiler is g++. They provide more options to the programmer than any other compiler. To know about these options please see the man pages of gcc. To see this please type out the following command at your shell,

     

     man gcc

  

     man g++

      (to see the options provided g++)

 

 

Now how do we use these compilers to compile our programs. Its simple, after creating a C or a CPP file named name.c or name.cpp, one of the following commands can be used to compile it.

 

gcc name.c    (use this for compiling a C file)   

 

g++ name.cpp  (use this for compiling a C++ file)   

     

This will compile and produce an executable file named a.out (similar to the creation of helloworld.exe when we use Turbo C++ compiler).

 

Executing

The next step is to run this executable file. In Linux, we will have to use the syntax given below to run any executable file.

 

 

  ./filename
where, filename is the name of an executable file. So, in this case we must give

 

 

  ./a.out

Comments (2)

sp2hari said

at 4:21 am on Jun 15, 2007

nice page. Proper for beginners :-) :-)
You can also mention the -o option for gcc and g++ and make command can also be used to compile the code.

vinod said

at 11:18 pm on Jun 22, 2007

i'll get it done.. :-)

You don't have permission to comment on this page.