|
So, you're using Linux at work. Thus far, all is as expected - it doesn't seem to crash, and is a damn sight nippier than most things you've used before. In short, life is good 
And then you find out that you need to install some software. Who knows what - a new version of MPlayer maybe, or a game to help kill some time. You visit the program's website, go to the download page, and then the problem smacks you in the face like a wet trout - how the heck do you install a program on Linux without administrator privileges?
Well, if you've got administrator privileges, it's a piece of cake. If you're running Debian/Ubuntu/Kubuntu Linux, it's normally a case of opening a console and typing "sudo apt-get install <progra>
", and that's it - Linux will automatically download the latest version of the program from the internet and install it for you. If you're running some variant of Red Hat/Mandrake/SuSE or something similar, then you just download a .rpm file and install it with "rpm -ivh ".
But we're at work. We don't have the administrator privileges needed to run those commands. And the administrator probably has far more important things to do than install every piece of software we're curious to try. But never fear, there is an answer - compiling the software and installing it into our home area...
It sounds scary, but when you get down to it and actually do it, it's pretty straightforward. It normally comes down to these simple steps:
1) Make a folder where you want to install your new program to. I tend to put each new program I compile in it's own folder in ~/.Software - the dot at the front of the directory name means that it's hidden by default, which keeps it nice and out of the way. But you can install it anywhere you like 
mkdir -p ~/.Software/MPlayer
2) Next step, go to the website in question, find the downloads section and look for a link to download the source code. The file in question will almost always have one of the following endings: ".tar.gz", ".tgz", or ".tar.bz2", for example "mplayer-1.0rc2.tar.gz" or "mplayer-1.0rc2.tar.bz2". Download this file to somewhere in your home area.
3) That file you downloaded is lots of files compressed together - just like a ".zip" file on windows. So just like on Windows, we need to uncompress it. Open a console, and "cd" to the directory where you saved the source file, and extract it with the tar command like this:
cd ~/Downloads/
tar -xf mplayer-1.0rc2.tar.bz2
4) That should have decompressed everything for us. Have a look for the new folder that'll have been created in the directory where you extracted those files, and "cd" into it. We now have to run a shell script called "configure". This script takes a look at our system and works out exactly how this software should be compiled and installed, and then generates these instructions in the form of "makefiles". Now, if we had administrative privileges, we could just run "./configure" at this point and be done with it. But we're not allowed to install software in the default location (/usr/local), so we have to tell the configure script that we want to install somewhere else. We do this by using the "--prefix" flag, followed by our chosen install directory:
./configure --prefix=/home/karl/.Software/MPlayer
This'll then generate our makefiles for us. Keep an eye out for serious error messages along the way (like missing pieces of software, for example). Note that configure needs the *full* install path - "~/.Software/MPlayer" wouldn't work. Also note that every software package normally has tons of unique command line options - typically for including or excluding pieces of functionality, for example. For the full list for a given package, run configure with the "-h" flag.
5) So, we have our makefiles. Would you believe it, the hard part's out of the way now. We can now compile the program just by running "make".
make
If anything goes wrong at this stage, you'll normally get several pages of errors. The first one is always the culprit, so scroll up until you find the first line with "error" in it. Depending on the speed of your machine and the complexity of what you're compiling, this stage can take a while... Coffee time! 
6) If make completed successfully, the program is now compiled. All that remains is to copy the program and everything it needs into its install directory:
make install
7) Your brand-spanking-new program is installed and ready to go! Go have a look in the install directory you created - the program itself will typically be in the "bin/" folder, with additional libraries in "lib/", settings files in "etc/" and images/sounds in "share". Depending on the program, you may need to add a few extra lines to your "~/.bashrc" file so our new program feels at home:
#Make sure we always run our new mplayer instead of the system-wide mplayer
export PATH="~/.Software/MPlayer/bin:$PATH"
#Make sure MPlayer uses the new libraries instead of the system-wide older ones
export LD_LIBRARY_PATH="~/.Software/MPlayer/lib:$LD_LIBRARY_PATH"
That's it, your new program is now ready to go. Most Linux programs do fall into this simple recipe - just ./configure; make; make install. Not as tough as it sounds at first...
|