0% found this document useful (0 votes)
3K views6 pages

Installing A C Compiler in The Virtual Machine and Executing A Sample Program

The document discusses installing and using the GCC compiler inside a virtual machine. It begins by explaining that GCC is a widely used open source compiler system produced by the GNU Project. It then outlines the steps to install GCC via the build-essential package in Ubuntu, which provides the compiler and other development tools. The document demonstrates how to compile a simple C program file called filename.c using GCC, and then run the resulting executable.

Uploaded by

riya k
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3K views6 pages

Installing A C Compiler in The Virtual Machine and Executing A Sample Program

The document discusses installing and using the GCC compiler inside a virtual machine. It begins by explaining that GCC is a widely used open source compiler system produced by the GNU Project. It then outlines the steps to install GCC via the build-essential package in Ubuntu, which provides the compiler and other development tools. The document demonstrates how to compile a simple C program file called filename.c using GCC, and then run the resulting executable.

Uploaded by

riya k
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

EX.

NO:6 Installing a C compiler in the virtual machine and executing a sample


DATE: program

AIM:
To install and work with GCC compiler inside a Virtual machine.

GCC COMPILER:
The GNU Compiler Collection (GCC) is a compiler system produced by the GNU
Project supporting various programming languages. GCC is a key component of the GNU
toolchain. The Free Software Foundation (FSF) distributes GCC under the GNU General Public
License (GNU GPL). GCC has played an important role in the growth of free software.

The GNU Compiler Collection – GCC – is one of the most complex software systems available
in full source form. It was initiated by the Free Software Foundation and today is steered by an
independent steering committee. While initially, it started off as a efficient C compiler for 32 bit
machines, it has evolved to a reasonable generic architecture that accommodates about 7 source
languages and a large number of target machines officially. The emphasis has been to have a
well tested compilation system for a large number of target machines.. The easy availability,
retargetability, the GNU license and continuing development have combined to make it a
standard reference implementation with respect to which specific implementations are often
compared today.

The GCC effort is mainly an engineering effort aimed at being of immediate use. As with any
other software engineering effort, it's concerns are with:

 Adhering to standards prescribed from time to time,


 Bugs removal management,
 Performance benchmarking, and
 Testing.

GCC started it's life as a C compiler. It's goal was to be a useful compiler for general use . It was
desirable that the compiler be retargetable to facilitate easy porting to new systems. A
retargetable architecture postpones target machine specific decisions to build time instead of
committing to specific machine properties earlier. This implies that the building process is
required to incorporate the target machine properties into the compiler code base. The GCC
today actively pursues the retargetability goal mainly because it results in a useful compiler. To
be useful is the primary goal and retargetability is viewed as a way to reach the goal. It aims to
support all the machines that are in operation at any given point in time. It is possible that
support for some machines gets withdrawn as their decreasing usage is not worth the effort to
support it.
The design and development goals are:

 New languages
 New optimizations
 New targets
 Improved run time libraries
 Faster debug cycle
 Various other infrastructure developments

GCC's external interface follows Unix conventions. Users invoke a language-specific driver
program ( gcc for C, g++ for C++, etc.), which interprets command arguments, calls the actual
compiler, runs the assembler on the output, and then optionally runs the linker to produce a
complete executable binary. GCC was written primarily in C except for parts of the Ada front
end. The distribution includes the standard libraries for Ada,C++, and Java whose code is mostly
written in those languages.

FrontEnd: Each front end uses a parser to produce the abstract syntax tree of a given source file.
Due to the syntax tree abstraction, source files of any of the different supported languages can be
processed by the same back end. GCC started out using LALR parsers generated with Bison, but
gradually switched to hand-written recursive-descent parsers.

BackEnd: The behavior of GCC's back end is partly specified by preprocessor macros and
functions specific to a target architecture, for instance to define its endianness, word size,
andcalling conventions. The front part of the back end uses these to help decide RTL generation,
so although GCC's RTL is nominally processor-independent, the initial sequence of abstract
instructions is already adapted to the target. At any moment, the actual RTL instructions forming
the program representation have to comply with the machine descriptionof the target
architecture.

The Features of GCC Compiler:

 Link-time optimization optimizes across object file boundaries to directly improve the linked
binary. Link-time optimization relies on an intermediate file containing the serialization of
some Gimple representation included in the object file.The file is generated alongside the
object file during source compilation. Each source compilation generates a separate object
file and link-time helper file. When the object files are linked, the compiler is executed again
and uses the helper files to optimize code across the separately compiled object files.
 Plugins can extend the GCC compiler directly. Plugins allow a stock compiler to be tailored
to specific needs by external code loaded as plugins. For example, plugins can add, replace,
or even remove middle-end passes operating on Gimple representations.
PROCEDURE:
Step1: To install the gcc , you will need the build-essential package. This
will also install GNU make.
build-essential contains a list of packages which are essential for building Ubuntu
packages including gcc compiler, make and other required tool

Step2:In Ubuntu,open the terminal and in that type the following command to install and
work with GCC compiler inside it.
sudo apt-get install build-essential

Step3:After proceeding with the above prescribed command,press ’ y’ to continue.

Step4: Create a file ,which you will want to compile using GCC compiler by typing the
following Unix command.
vi filename.c
Step5:You are provided with a new workspace .In that type the program which you will
need to be compiled using GCC compiler.

Step6:After creating a file,compile the program using the following Unix command.
gcc filename.c

Step7:Then run the program with the help of the following command.
./a.out
RESULT:
Thus the procedure for installation and working of GCC compiler inside a virtual
machine was executed successfully.

You might also like