Building source from apt

From LSDevLinux
Jump to: navigation, search

Debian provides a few tools for building source packages downloaded from apt. This is useful for building debugging versions of libraries. Note that you may need to install build-essentials, fakeroot and cdbs before you start to build.

Obtaining the sources

Create a directory to unpack the sources into, and download:

$ mkdir xyz
$ cd xyz
$ apt-get source libxyz-1.0

Note that this is done as a regular user

Build the sources

Download the supporting packages and build the source.

$ sudo apt-get build-dep libxyz-1.0
$ cd libxyz-1.0
$ CXXFLAGS=-g fakeroot debian/rules binary

Note the CXXFLAGS part is only needed to build a debugging version of the package. You can use -j2 if you are on a dual processor system.

Use them for your own program

You will need to find the include and lib directories, which will be somewhere below the debian directory. Something similar to the following lines can then be added to your makefile:

CXXFLAGS += -I xyz/libxyz-1.0/debian/.../include
LDFLAGS  += -L xyz/libxyz-1.0/debian/.../lib