Those are archives. You need to unpack them and see for instructions inside. Usually it's ./configure, make, make install, but I'm sure someone will provide better answer to you, with links where you can learn this very basic things before you actually try to build anything
–
zetahApr 30 '12 at 14:57

3

Depending on what you want to install, you need also to install the build-essential package and -dev packages of the libraries which are used by the software. Take care that you install to the prefix /usr/local/ (which is normally the default), otherwise you may corrupt your system. For a beginner, I suggest you strongly to restrict yourself to the available packages from Debian. The next step would be to search for already packaged software (.deb packages) and install them then by hand dpkg -i ./path/to/package.deb. Using .tar.{gz,bz2} packages, is the last and most difficult option.
–
jofelApr 30 '12 at 16:18

@jofel I agree with you, but some programs are not available in a .deb package and you can only install it from the source code (e.g. Firefox).
–
ZigndOct 30 '12 at 10:21

1

Firefox is most definitely available in the repositories and rarely needs to be built from source.
–
Daemon of ChaosOct 30 '12 at 13:03

@KayakJim I remember that I never could install it from Debian repository. But I'm sure that it's available in the Ubuntu repository.
–
ZigndOct 31 '12 at 10:02

From sources

A source package is going to be more troublesome (by far) and through they can roughly be processed with the method below, each package is different:

download the package to /usr/local/src

tar xf <file>.tar.[bz2|gz]

cd <package name>

read the README file (this almost certainly exists).

most Open Source projects use autoconf/automake, the instructions should be in the README. Probably this step will go: ./configure && make && make install (run the commands separately for sanity if something goes wrong though).

If there's any problems in the install then you'll have to ask specific questions. You might have problems of incorrect versions of libraries or missing dependencies. There's a reason that Debian packages everything up for you. And there is a reason Debian stable runs old packages - finding all the corner cases of installing packages on more than a dozen different architectures and countless different hardware/systems configurations is difficult. When you install something on your own you might run into one of these problems!

Unpack the files and then, in the directory that was created, look for a README or INSTALL file which will tell you what you need to know in order to install a package (e.g. dependencies, configuration options, commands to run etc...).

Note that the build will most likely fail in configure. Why? Because the source you've downloaded probably has build time dependencies you don't have installed. On Debian/Ubuntu, if the package also is available with apt, you can install these with: sudo apt-get build-dep package-name
–
anonfuncNov 1 '12 at 18:53

Generally speaking, when you install tar.gz/tgz/tar/bz2 (remember, these are just compressed package files) you would need to break open the tar file (tar xvfz/tar xvfj) and then cd to the directory and run ./configure.

On some systems, you either take the defaults (/usr/local/{lib,bin,etc...} for example) as the default install location, or you might like to use /opt/local/{lib,bin,etc}.

So you would do ./configure --prefix=/usr/local and then make, make install.

It us up to you where you want to install your packages. Remember that where ever you decide to do it, you might want to add the path to your PATH shell variable so you can easily run those packages. (often export PATH=$PATH:/opt/local/bin:/usr/local/bin).

Let me illustrate this with an example, say you wish to install a package abc.
The dependencies of the package abc may be identified by reading its documentation. You should resolve the dependencies(required libraries etc) prior to installation for a smooth experience.

Before a gcc 4.7.2 build the g++, m4, gawk, gcc-multilib,
gmp, mpfr, and mpc must be built.

Then comes the building from source part for which the first step is always extraction. This can be done by using the tar command or by the simple GUI way. Once you have the extracted files in a folder you must browse to that folder using the cd command, for example if the contents are in Downloads then:

$cd Downloads/abc

Now you need to run ./configure. Specify the installation directory by using the --prefix= option with configure.

Firstly, according to the File System Hierarchy Standards, the
location of this installed package should be /opt if it is a binary
install and /usr/local if it's a from source install.

so if you are installing to the /usr/abc directory you will supply the option --prefix=/usr/abc with the ./configure instruction.

$./configure --prefix=/usr/abc

--prefix= is not the only thing you might want to specify though, you might want to supply other information for a successful compilation like the type of your system with --build=x86_64-linux-gnu for 64 bit, and --build=i386-linux-gnu for a 32 bit system. It is wise to read the README in the extracted files as it may carry the information about which options to specify with the ./configure command.

After the ./configure run the make command, and subsequently the make install.
Post installation you should specify the library path, shell/environment variables using the export command.