Friday, June 10, 2005

running software

Running the software

You are now ready to run the software (assuming everything worked).

% cd ~/units174

If you list the contents of the units directory, you will see a number
of subdirectories.
bin The binary executables
info GNU info formatted documentation
man Man pages
share Shared data files

To run the program, change to the bin directory and type

% ./units

As an example, convert 6 feet to metres.

You have: 6 feet

You want: metres

* 1.8288

If you get the answer 1.8288, congratulations, it worked.

To view what units it can convert between, view the data file in the
share directory (the list is quite comprehensive).

To read the full documentation, change into the info directory and type

% info --file=units.info
7.7 Stripping unnecessary code

When a piece of software is being developed, it is useful for the
programmer to include debugging information into the resulting
executable. This way, if there are problems encountered when running
the executable, the programmer can load the executable into a
debugging software package and track down any software bugs.

This is useful for the programmer, but unnecessary for the user. We
can assume that the package, once finished and available for download
has already been tested and debugged. However, when we compiled the
software above, debugging information was still compiled into the
final executable. Since it is unlikey that we are going to need this
debugging information, we can strip it out of the final executable.
One of the advantages of this is a much smaller executable, which
should run slightly faster.

What we are going to do is look at the before and after size of the
binary file. First change into the bin directory of the units
installation directory.

% cd ~/units174/bin

% ls -l

As you can see, the file is over 100 kbytes in size. You can get more
information on the type of file by using the file command.

% file units

units: ELF 32-bit LSB executable, Intel 80386, version 1, dynamically
linked (uses shared libs), not stripped

To strip all the debug and line numbering information out of the
binary file, use the strip command

% strip units

% ls -l

As you can see, the file is now 36 kbytes - a third of its original
size. Two thirds of the binary file was debug code !!!

Check the file information again.

% file units

units: ELF 32-bit LSB executable, Intel 80386, version 1, dynamically
linked (uses shared libs), stripped

HINT: You can use the make command to install pre-stripped copies of
all the binary files when you install the package.

Instead of typing make install, simply type make install-strip

0 Comments:

Post a Comment

<< Home