Ben Chaco approached me last night at the PLUG meeting with a question
about installing a program from source code. I figured that there are
other people on this list that may benefit from this explanation as well,
so here's a very basic intro:
somefile.tar <-- this is a "tar" file which is basically just a
bunch of files packed into one.
somefile.tar.gz <-- this is a "gzipped" tar file which is a tar file
that has been compressed using the gzip program (tar also has the ability
to compress and uncompress files).
So usually when you get a file like this, it's source code, which means
you'll have to compile the program yourself before you can use it.
Compiling programs usually "just works" on Linux, but last night we ran
into a problem with a missing library, so the program didn't compile
comletely.
OK, so here are the most common tar commands for dealing with the above
file types:
tar zxf somefile.tar.gz <-- the "z" option tells tar to uncompress it
since we're also using it with the "x" option which tells it to extract
the contents of the tar file, and then should create a directory
containing all of the files that were originally packed together. If you
want to see a display of the files as they're untarred, you can add the
"v" option. The "f" option must be the last option because the name
following the "f" specifies the file name to use.
If the file is just called somefile.tar, then it's most likely not gzipped
so you can leave off the "z" option.
Now, let's say you want to create your own tarred and gzipped file to send
to someone or for backup purposes. Just substitute a "c" (for compress)
in place of the "x" (for extract), like this:
tar zcf mystuff.tar.gz mystuff <-- you specify the name of the
archive as "mystuff.tar.gz" then you tell it which directory to use. In
this case, we're using "mystuff".
There are many other options to tar and ways of using it, but these will
help you get started.
Alright, so now that you've unpacked your source code, you're ready to
configure and build your program. In most cases, you can simply type the
following commands:
./configure <-- runs a configure script that prepares for the build
make <-- compiles the program
make install <-- This step copies the newly compiled binaries to a
default location on your system (assuming you didn't specify a different
install directory with the configure script)
At this point if everything compiled successfully, then you should be able
to type the name of the program to run it. Alternatively, you may want to
browse to the location of the program and drag the icon to your desktop or
toolbar for future use (this, of course, depends on the Windowing
environment you use).
What I usually do is create a directory called "local" in my home
directory, then I tell the configure script to install there instead of
the default (usually /usr/local/). Here's how you'd do that:
./configure --prefix=$HOME/local
So now when you run make install, you don't have to be root. The entire
program is installed under the local directory in your home directory.
Also, be sure that $HOME/local/bin (and possibly $HOME/local/sbin) is in
your PATH.
~M