You might sometimes want to recompile a package, even though a binary package is available in the Ubuntu repositories. For example, a program might have been compiled into a binary with a specific feature disabled that you would like to use. Here is how you can do this. We will call the software package we want to compile foo.
First, get the source from the Ubuntu repositories:
matthew@seymour:~$ apt-get source foo
Install the build dependencies for the package:
matthew@seymour:~$ sudo apt-get build-dep foo
Change to the directory for the source code (may include the version number):