Simply, Compiling From Source
by Jeff Turcotte - November 7, 2006 / 12:48pm View more articles
Being relatively new to Unix/Linux, I was constantly looking for guides on how to perform different tasks. One area that I found to be lacking was a simple guide/explanation to compiling from source.
As of late, distributions have made installing software so easy that a lot of general users don't tend to care about compiling from source. What most don't realize is that your choice of, and ability to customize software increase dramatically. Plus, it's just cooler to watch a program compile than it is to download 'packages', etc.
Here is a simple explanation of how to perform this simple, yet valuable skill! As an example, I will be installing Vim 7.0 from source. You will most likely need root access to perform these commands. If you have any missing libraries/programs you should be told which ones you need in the process.
1. Get the source into your /usr/local/src/ directory.
go to /usr/local/src/:
get the source:
cd /pub/vim/unix/
get vim-7.0.tar.bz2
quit
extract the files:
2. Running the configure shell script.
This step will most likely exist, but not everyone includes a configure script with the source. With the Vim install, this step doesn't take very long, but be warned that sometimes it is notoriously long. Go get a drink:
3. Compile with Make.
Time to do the actual compiling and to go get another drink:
4. Put everything where it should be with Make Install
If everything was successful, lets move the compiled program to its appropriate place in the file system.
5. Clean up the temporary files with Make Clean
Compiling uses a lot of temp junk files that you can now get rid of. This process is automated with:
6. Restart terminal session and run it!
Lets see where Vim is! (/usr/local/bin/)
now run it:
Everything works! Now go compile more source code. The end.
Comments have been turned off on this blog.
Read something more recent.
Hiring: We’re hiring a
9 Comments
What I'd like to see is what to do when installs go wrong. I know there's no way to explain what will happen in every case, but a list of the most typical explanations would really come in handy.
I'd say about 50% of the time this doesn't work for me, and I can find NO help on how to fix the problem. It's frustrating to say the least.
It seems that a lot of README files are written from the perspective of the person(s) that created the (program|module|whatever), and that's where it all goes wrong. Get someone that doesn't know the process in there and see what questions they have. Write things from their point of view.
Anyway, nice blog.
I'd Scoop it...
.........
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' cr.................
"What most don't realize is that your choice of, and ability to customize software increase dramatically".
Where, in your example, does the customization part happen?
RTFM! (which would be the README in this particular case)