Ubuntu : Install (and remove) all packages needed to build a source code

Ubuntu users (or others who hate Ubuntu) always complain about dependency problems while building something from source. Well, there is a very easy way to solve all those library and other dependency problems. Just use the following ::

$sudo apt-get build-dep <source-package-name>

I have posted this directly from the APT HOWTO . Check it out for a better understanding of APT’s power.

Installing all the build-deps is easy enough but they are (usually) useless once the comilation job is done. So, can they be removed as easily?

There are few options to do this –

  • /etc/apt/apt.conf
After this bug was fixed, we now have a option in apt.conf to see if the build deps should be removed when apt-get autmoremove is executed or not. To set them to be removed, add the following to your apt.conf file ( this file is usually not present, create it.)
    // Options for apt-get
     Build-Dep-Automatic "true";

Now whatever packages are installed using apt-get build-dep will be removed when you execute apt-get autoremove.

/usr/share/doc/apt/examples/configure-index.gz is a configuration file showing example values for all possible options.

  • Command line option

If you want to/don’t want to remove the build-deps of a particular package, pass the following option while using the build-deps command.

sudo apt-get build-dep -o APT::Get::Build-Dep-Automatic=true

True – To be removable by autoremove, False – otherwise.

  • If you want to do it after having used build-dep

Well, so far I have been unable to find anything that can reverse the effect after you have already installed the packages. There are some suggestions here and here but I found that they remove cross dependencies as well ( not good 😦 )


7 Responses to “Ubuntu : Install (and remove) all packages needed to build a source code”

  1. Aditya Says:

    Good one! I’ve always had a hard time meeting all the dependencies while installing amd64 packages, made me use the 32-bit variant…this seems helpful!

  2. Furquan Says:

    Hey….Thanku soooooooooooo much..helped a lot πŸ™‚

  3. Jitesh Says:

    I strongly recommend using pbuilder (https://wiki.ubuntu.com/PbuilderHowto) instead of messing up your own system. The advantage is it chroots into a use-and-throwable rootfs and hence, can be discarded/remade whenever you want + you don’t need to worry about erasing unnecessarily installed packages.

  4. sindhu Says:

    This was posted on OCt 6th and the first comment by Aditya dates to Sep 7, 2008? o_O

    • CDK Says:

      The previous post which was posted on Set7, 2008 only had the install part. I added the remove part yesterday and changed the date.

  5. Amod Jaltade Says:

    nice ! πŸ™‚
    keep us update us when you find some way πŸ™‚

  6. Amod Jaltade Says:

    grammar chukla πŸ˜›

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: