Compiling in Linux

Associate
Joined
20 Jul 2006
Posts
258
So i've been reading about and heard a lot of referencing to compiling your own programs and stuff. I also have a VERY limited knowledge of compiling and only done some extremely small compiling while at school using Visual Basics and the sort so im not sure if this will tie in.

But what I THINK the case is, that you get the source code and compile it. Basically. But what are the benefits of this? Wouldn't it be better to just use the precompiled programs to save time. Like why compile it yourself, if you can just download the already compiled program from the website or whatnot. I just need some clarification on why, how, and when to compile programs myself.
 
well you mostly do download binaries that have been pre-compiled. but some projects the author only has one version of linux and you need to compile your own binary (i.e redhat and ubuntu would have diff binares)

tis not hard to "make" thou :)
 
The reason to compile programs your self is when either there is no binary package available for it, or you want an optimized version for your current architecture (I.e gentoo style). There are also patches released and you need to apply those to the source code, if you wish to make use of the changes.

The most common compiling you do on linux is the kernel, to strip out all the crap you don't need and make the size smaller (or large by adding more features) , and custom for your current spec.
 
Last edited:
If there is a binary and it works, use it, simple as that :)
Compilation is only really necessary in these circumstances-
1. No binary.
2. X64 systems- Precompiled binaries are less common for these.
3. Custom compiled kernel- From your post, I would say you are nowhere near having to worry about this ;)
4. Binary doesn't work. This is actually not quite true- More often than not, its the error messages from the config output that are useful here, as a binary not working is ususally a dependancy problem.
5. You are worried about every last bit of performance you can drag out of your system. (Even then, the gains are none to very minimal)

Compilation of a program is incredibly simple-
1. Download the source
2. Extract it somewhere- For this, I'll use the directory of /home/example/myprogram
3. Open a terminal, and CD to where you just extracted it:
Code:
 cd /home/example/myprogram
4. Configure the program for being built:
Code:
./configure
5. If you've been lucky, you can simply build the program-
Code:
 sudo make
(You'll need to enter your password here)
6. Now install any libraries etc. that were just built:
Code:
sudo make install
(You'll need to enter your password here)
Depending on how the programs build has been setup, you should then be able to launch it from the app it will have built in this directory, or by typing the name of the program into the command line. If it's just a library, you should be able to delete the directory now.
7. However, if there were errors from the configuration output, you'll need to correct these. Usually these'll be in the form of ABC not found. ABC will normally be the name of a dependancy- Unless its something pretty specialised, these should be able to be installed from your distros package manager, otherwise download and compile them as above :)

Hope that helps :D

-Leezer-
 
I see. So if I download the source of Ubuntu, compile it on the SAME machine as I would install it onto, it would make it more specific for me? With performance boost and whatnot.
 
Well yeah, you could install it in a similar way to a source distribution, its possible but hardly very practical and certainly not easy if your a noob.

If you are going down that route you may as well look at gentoo/linux from scratch.....

I would stick with Ubuntu (Edgy). It is really nice and the performance benefits you get from building from source are easily outweighed by the time it takes to compile and the dependency hell with libs.
 
i've compiled a few programs from source, but to be honest, it's a pain in the backside and it's not really worth the hassle for the miniscule performance you may or may not notice.
 
Steve Watford said:
I see. So if I download the source of Ubuntu, compile it on the SAME machine as I would install it onto, it would make it more specific for me? With performance boost and whatnot.

If you even have to ask that question, then no :p
Download a copy of the Linux kernel & untar it somewhere. Using the command prompt run:
Code:
make menuconfig
When you can understand at least some of the options in there and the effect/ otherwise they'll have on your PC, thats when you want to start building your OS from source ;)

-Leezer-
 
Back
Top Bottom