HOWTO: Compiling 101
Quite often, on scanning some of the more n00b-oriented forums (fora?), I will come across the perennial “I have to actually compile something?! WTFOMFG! Linux is sooo not ready for the desktop! How the hell am I supposed to perform such brain surgery?” posts. Not that I’m picking on anyone. In fact, for the bash virgins, compiling source can oft be a source of fear and frustration, and I think one of the unintended side-effects of n00b-ready distros like Ubuntu and PCLinuxOS is that the “you should never have to compile anything” mentality, while good by itself (I use aptitude for installation of new software whenever possible), ultimately is a disservice to first-time users, because a month or five down the trail they’re going to run into something that’s not in the repositories that they want, and because no one’s ever explained to them what the compiling process is and how it works, they’re going to go apeshit like the (completely fabricated) fictional n00b poster above. The following is a ten-step recipe for compling code, and found on the Kubuntu mailing list, originally posted by Luís Silva, and reprinted here with his gracious permission. May it find the eyes that need to see it most.
A tar.gz is a set of files that was first archived with tar and then
compressed with gzip. You will also often find tar.bz2. The difference being
the compression utility used, in this case bzip2. tar itself can handle them
both.Here is how it goes:
1- Create a folder named BUILD in your /home/YourUserName (This is just to
keep your home tidy!)
2- move/copy the tar.gz into this folder
3- I suppose you have already used the command line before. If you did the
above in the command line just cd to the BUILD folder. If not, open a
terminal, type “cd” (without the “) (this is to make sure you are in your
home folder), type “cd BUILD”.
4- Now you are in the BUILD folder, you are going to unzip and untar the file:
tar vxzf yourfile.tar.gz
The “v” is for verbose, the “x” is for extract, “z” is because you have a
gziped file (you should use “j” instead if you had a tar.bz2), and the “f” is
to say that the next word is going to be your file name.
5- now you should have a new folder there. Check it with “ls -hl”
6- “cd” to the new folder.
7- Each program in source code comes with one or several scripts that perform
the actual compilation and installation for you. Typically you have
a “configure” script there. Again, check it with “ls -hl”. Run it
with “./configure”
8- If you get any errors just post them here so we can help you going through
them. If don’t just type “make”. This should compile your program.
9- If everything went as expected, and you want to install the program in your
system type “sudo make install” and enter your password when asked for it.
10- That’s it. There are surely a lot of things I omitted. If you want to know
more about each command you used (and you should be learning about these)
type ‘man command’ on the command line (replacing command by what you want to
know about.A nice thing about kde (I assume you are using kde) is that you have man, info
and help available in konqueror. So typing man:command, info:command or
help:command in the location bar gives you help on the desired command. For a
newbie I would recommend its EXTENSIVE use.Ok! Have fun and keep trying. Don’t stop just because something didn’t work
the first time.
That’s great advice at the end. Don’t quit on it just because you can’t figure it out right away. Maybe you’re missing a library somewhere, or the configure script is looking for something that you do have, but in an unexpected place. Keep poking, put up forum posts, trawl IRC channels. Email the author if you have to. Everything worth doing is hard and scary the first time. There’s a whole big raft of people waiting to help you. Good luck!
-pd-
April 4, 2008 at 2:28 am
“Fori” The plural of forum is “fori”
April 4, 2008 at 5:16 pm
HTML 101
<pre>