Contact us |
Building Software from SourceIn this exercise you are going to download, compile and install a software from its source files. You may sometimes have need to do this for a number of reasons. Here you will install a program that is distributed in a “tar-dot-gzip” format (also called a tarball)To download the source file 1. You should have downloaded the tarball file called “hello-2.1.1.tar.gz” in an earlier Lab. The file is supposed to be in the “/usr/local/src/downloads” directory. If you didn’t download it then you should now connect to your central package repository location to obtain the file. You may also download the file directly from the internet, if you have a connection to the internet (and you probably do if you are reading this http://www.gnu.org/software/hello/hello.html To un-tar the file 1. Change to the directory on your local machine where you downloaded the file. 2. You will now unpack (un-tar) the tarball using the “tar” program. Type: [root@localhost downloads]# tar -xvzf hello-2.1.1.tar.gz hello-2.1.1/ hello-2.1.1/intl/ hello-2.1.1/intl/ChangeLog hello-2.1.1/intl/Makefile.in hello-2.1.1/intl/config.charset hello-2.1.1/intl/locale.alias hello-2.1.1/intl/ref-add.sin ............................................. 3. Use the “ls” command to view the contents of your pwd. Type: [root@localhost downloads]# ls hello-2.1.1 hello-2.1.1.tar.gz A new directory called “hello-2.1.1” should have been created for you during the un-taring. 4. Change to the new directory. And list its contents. Type: [root@localhost downloads]# cd hello-2.1.1 ; ls 5. It is always a good idea, when installing programs from source to look for and carefully study any installation instructions the developers may have provided with the program. Those files usually have names like: INSTALL, README etc.. Use a pager to open up the INSTALL file and read it. Type: [root@localhost hello-2.1.1]# less INSTALL Exit the pager when you are done reading the file. To configure the packageMost packages have certain features that can be enabled or disabled by the user. This is one of the reasons why installing from source files comes in handy- you have almost total control to take only what you want (as opposed to accepting everything a package manager feels will be useful to you ) The script that usually lets you configure the software is usually aptly named “configure” 1. Use the “ls –l” command again to make sure that you indeed have a file called configure in your pwd. Write down the permissions on the file? 2. To see all the options you can enable or disable in the program type: [root@localhost hello-2.1.1]# ./configure - - help From the output of the command what does the “- - prefix” option do? 3. If you are happy with the default options that the “configure “ script offers. Type:
[root@localhost hello-2.1.1]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking for gawk... gawk
checking whether make sets ${MAKE}... yes
checking for gcc... gcc
checking for C compiler default output... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
…………….
NOTES:Hopefully the configure stage went smoothly and you can go on to the compilation stage. If you got some errors during the configure stage, you should carefully look through the output to see the source of the error. The errors are sometimes self explanatory and easy to fix. For example you might see an error like: configure: error: no acceptable C compiler found in $PATH The above error simply means that you don’t have a C Compiler (e.g. gcc) installed on the system or the installer is installed somewhere that is not in your PATH variable. To compile the package1. Use the “make” command to compile the package after successfully running the “configure” script. Type: [root@localhost hello-2.1.1]# make <OUTPUT TRUNCATED> make[2]: Entering directory `/usr/local/src/downloads/hello-2.1.1/man' perl help2man --name="Friendly Greeting Program" ../src/hello >hello.1 make[2]: Leaving directory `/usr/local/src/downloads/hello-2.1.1/man' Making all in m4 <OUTPUT TRUNCATED> If all goes well (i.e. no serious error messages), go on and install the package. To install the software1. After the compile is done you need to install the package using the “make” command again. Type: [root@localhost hello-2.1.1]# make install This will install package into the location specified by the default prefix (-- prefix) argument that was used with the “configure” script earlier. To run the program1. Try running the program both as the superuser and as a regular user. The executable for the program you installed above is “hello”. To test the program as the superuser type: [root@localhost hello-2.1.1]# hello Hello, world! It is good practice to test a program as a regular user to make sure that regular users can indeed use the program. It is possible that the permissions on the binary are set incorrectly such that only the super-user can use the programs. This of course assumes that you indeed want regular users to be able to use the program. 2. That’s it you are done!!
|
Login... |