Differences between revisions 6 and 7
Revision 6 as of 2020-04-12 16:00:22
Size: 4349
Comment: better reflect page content
Revision 7 as of 2020-04-13 02:32:04
Size: 2959
Editor: PaulWise
Comment: cleanup
Deletions are marked like this. Additions are marked like this.
Line 8: Line 8:
Line 11: Line 12:
apt-get install build-essential}}} apt install build-essential
}}}
Line 16: Line 18:
apt-get install build-essential libncurses5-dev}}} apt install build-essential libncurses5-dev
}}}
Line 18: Line 21:
== What do I need to build GTK+ programs? == == What do I need to build GTK programs? ==
Line 21: Line 24:
apt-get install libgtk1.2-dev}}}
for GTK+, or
{{{
apt-get install libgtk2.0-dev}}}
for GTK+2. No, you cannot compile a GTK+ application against GTK+2. The APIs are not compatible.
apt install libgtk-3-dev
}}}
Line 27: Line 27:
== What do I need to build programs that require glib, but not GTK+? == == What do I need to build programs that require glib, but not GTK? ==
Line 30: Line 30:
apt-get install libglib1.2-dev}}}

but note that this should be relatively rare, since usually you will have acquired libglib1.2-dev by installing libgtk1.2-dev.
apt install libglib2.0-dev
}}}
Line 37: Line 36:
apt-get install libqt3-mt-dev}}} apt install qtbase5-dev
}}}
Line 42: Line 42:
apt-get install libsdl1.2-dev}}} apt install libsdl2-dev
}}}
Line 47: Line 48:
apt-get install zlib1g-dev}}} apt install libz-dev
}}}
Line 49: Line 51:
== What do I need to build programs that use X? == == How do I build a Linux kernel the Debian way? ==
Line 52: Line 54:
apt-get install xlibs-dev}}} apt install build-essential kernel-package
}}}
Line 54: Line 57:
== How do I build a kernel the Debian way? == Also install {{{libncurses-dev}}} if you want to use menuconfig, or {{{libgtk2.0-dev}}} for gconfig.

Extract your Linux kernel source, cd into the resulting directory, apply any patches you wanted (optional), then run the command
Line 57: Line 62:
apt-get install build-essential kernel-package}}} make bindeb-pkg EXTRAVERSION=custom.1
}}}
Line 59: Line 65:
Also install {{{libncurses5-dev}}} if you want to use menuconfig, or {{{libgtk1.2-dev}}} for gconfig in 2.6. Install {{{bin86}}} for 2.2 or earlier kernels on the i386 architecture. This should create several {{{.deb}}} files in the parent directory. You can change the revision string to include a hostname, etc.
Line 61: Line 67:
Extract your kernel source, cd into the resulting directory, apply any patches you wanted (optional), then run the command If you're building older Linux kernel sources on newer versions of Debian, you may have to use an older version of gcc than the default.

The building process is quite slow so you can use {{{ccache}}} to speed it up
(helps after the first build). In order to do so you'll need to set it up before building:
Line 64: Line 73:
make-kpkg --revision=custom.1 binary-arch}}}

This should create two {{{.deb}}} files in the parent directory. You can change the revision string to include a hostname, etc.

If you have third party modules in {{{/usr/src/modules/}}} then add {{{modules_image}}} to the end of the make-kpkg command to build a package for the modules. (This applies to PCMCIA, NVidia, ATI, etc. It doesn't apply to modules which are part of the Linux source tree, that you marked with {{{M}}}.)

If you're building older kernel sources on newer versions of Debian, you may have to use an older version of gcc than the default.

The building process is quite slow so you can use {{{ccache}}} to speed it up
(helps after the first build). In order to do so you'll need to instruct
{{{make-kpkg}}} to use it like that:

{{{
MAKEFLAGS='CC=ccache\ gcc'
export MAKEFLAGS}}}

Note that the quotes and the backslash are important for {{{ccache}}} to work
properly. Without them the build will fail.
export PATH="/usr/lib/ccache:$PATH"
}}}
Line 89: Line 82:
First, add a {{{deb-src}}} line to your sources.list file. For example, First, add a {{{deb-src}}} entry to your [[SourcesList|apt sources]].

If you're trying to build a backport, you may want testing instead of stable. It won't affect your system because this is only source code. Then:
Line 92: Line 87:
deb-src http://http.us.debian.org/debian/ lenny main contrib non-free}}}

(If you're trying to build a backport, you may want sid instead of lenny. It won't hurt you because this is only source code.) Then:

{{{
apt-get update
apt-get build-dep mypackage
apt-get -b source mypackage}}}
apt update
apt build-dep mypackage
apt -b source mypackage
}}}
Line 104: Line 95:
fakeroot debian/rules binary}}}

##(or {{{dpkg-buildpackage -uc -us -rfakeroot}}} if you prefer). For more details, see the next question.
(or {{{dpkg-buildpackage -uc -us -rfakeroot}}} if you prefer).

## HTTP 404 as at 2009-07-16
##== Is there a good howto on building debian packages? ==
##
##Try http://www.linuks.mine.nu/irc/debian-packaging/ which is a very short introduction with nice pointers.
dpkg-buildpackage
}}}

Translation(s): English - Italiano

(!) ?Discussion

Development questions

I'm trying to build something and it says "C compiler cannot create executables".

apt install build-essential

I'm trying to configure my kernel with make menuconfig, and it says "curses.h not found".

apt install build-essential libncurses5-dev

What do I need to build GTK programs?

apt install libgtk-3-dev

What do I need to build programs that require glib, but not GTK?

apt install libglib2.0-dev

What do I need to build QT programs?

apt install qtbase5-dev

What do I need to build SDL programs?

apt install libsdl2-dev

What do I need to build programs that use libz?

apt install libz-dev

How do I build a Linux kernel the Debian way?

apt install build-essential kernel-package

Also install libncurses-dev if you want to use menuconfig, or libgtk2.0-dev for gconfig.

Extract your Linux kernel source, cd into the resulting directory, apply any patches you wanted (optional), then run the command

make bindeb-pkg EXTRAVERSION=custom.1

This should create several .deb files in the parent directory. You can change the revision string to include a hostname, etc.

If you're building older Linux kernel sources on newer versions of Debian, you may have to use an older version of gcc than the default.

The building process is quite slow so you can use ccache to speed it up (helps after the first build). In order to do so you'll need to set it up before building:

export PATH="/usr/lib/ccache:$PATH"

Speeding up the build even more is possible by using distcc. More information how to combine distcc and ccache is available here.

How do I recompile a Debian package from source?

First, add a deb-src entry to your apt sources.

If you're trying to build a backport, you may want testing instead of stable. It won't affect your system because this is only source code. Then:

apt update
apt build-dep mypackage
apt -b source mypackage

The resulting .deb files will be in the current directory. If you want to make modifications to the source code before you build it, then omit the -b option, cd into the resulting directory, make your changes, and then run:

dpkg-buildpackage

How do I recompile packages with CPU-specific optimizations?

Install the pentium-builder package and read the instructions.