📄 gtk-building.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"><title>Compiling the GTK+ libraries</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2"><link rel="start" href="index.html" title="GTK+ Reference Manual"><link rel="up" href="gtk.html" title="Part I. GTK+ Overview"><link rel="prev" href="gtk.html" title="Part I. GTK+ Overview"><link rel="next" href="gtk-compiling.html" title="Compiling GTK+ Applications"><meta name="generator" content="GTK-Doc V1.9 (XML mode)"><link rel="stylesheet" href="style.css" type="text/css"><link rel="part" href="gtk.html" title="Part I. GTK+ Overview"><link rel="part" href="gtkbase.html" title="Part II. GTK+ Core Reference"><link rel="part" href="gtkobjects.html" title="Part III. GTK+ Widgets and Objects"><link rel="chapter" href="ch01.html" title="Object Hierarchy"><link rel="chapter" href="ch02.html" title="Widget Gallery"><link rel="chapter" href="WindowWidgets.html" title="Windows"><link rel="chapter" href="DisplayWidgets.html" title="Display Widgets"><link rel="chapter" href="ButtonWidgets.html" title="Buttons and Toggles"><link rel="chapter" href="NumericEntry.html" title="Numeric/Text Data Entry"><link rel="chapter" href="TextWidgetObjects.html" title="Multiline Text Editor"><link rel="chapter" href="TreeWidgetObjects.html" title="Tree, List and Icon Grid Widgets"><link rel="chapter" href="MenusAndCombos.html" title="Menus, Combo Box, Toolbar"><link rel="chapter" href="Actions.html" title="Action-based menus and toolbars"><link rel="chapter" href="SelectorWidgets.html" title="Selectors (File/Font/Color/Input Devices)"><link rel="chapter" href="LayoutContainers.html" title="Layout Containers"><link rel="chapter" href="Ornaments.html" title="Ornaments"><link rel="chapter" href="ScrollingWidgets.html" title="Scrolling"><link rel="chapter" href="Printing.html" title="Printing"><link rel="chapter" href="MiscObjects.html" title="Miscellaneous"><link rel="chapter" href="AbstractObjects.html" title="Abstract Base Classes"><link rel="chapter" href="PlugSocket.html" title="Cross-process Embedding"><link rel="chapter" href="SpecialObjects.html" title="Special-purpose features"><link rel="chapter" href="RecentDocuments.html" title="Recently Used Documents"><link rel="chapter" href="Builder.html" title="Interface builder"><link rel="chapter" href="DeprecatedObjects.html" title="Deprecated"><link rel="part" href="migrating.html" title="Part IV. Migrating from Previous Versions of GTK+"><link rel="chapter" href="gtk-migrating-checklist.html" title="Migration Checklist"><link rel="chapter" href="gtk-migrating-GtkFileChooser.html" title="Migrating from GtkFileSelection to GtkFileChooser"><link rel="chapter" href="gtk-migrating-GtkAction.html" title="Migrating from old menu and toolbar systems to GtkAction"><link rel="chapter" href="gtk-migrating-GtkComboBox.html" title="Migrating from GtkOptionMenu and GtkCombo to GtkComboBox and GtkComboBoxEntry"><link rel="chapter" href="gtk-migrating-GtkIconView.html" title="Migrating from GnomeIconList to GtkIconView"><link rel="chapter" href="gtk-migrating-GtkAboutDialog.html" title="Migrating from GnomeAbout to GtkAboutDialog"><link rel="chapter" href="gtk-migrating-GtkColorButton.html" title="Migrating from GnomeColorPicker to GtkColorButton"><link rel="chapter" href="gtk-migrating-GtkAssistant.html" title="Migrating from GnomeDruid to GtkAssistant"><link rel="chapter" href="gtk-migrating-GtkRecentChooser.html" title="Migrating from EggRecent to GtkRecentChooser"><link rel="chapter" href="gtk-migrating-GtkLinkButton.html" title="Migrating from GnomeHRef to GtkLinkButton"><link rel="chapter" href="gtk-migrating-GtkBuilder.html" title="Migrating from libglade to GtkBuilder"><link rel="chapter" href="gtk-migrating-tooltips.html" title="Migrating from GtkTooltips to GtkTooltip"><link rel="part" href="pt05.html" title="Part V. GTK+ Tools"><link rel="glossary" href="glossary.html" title="Glossary"><link rel="index" href="ix01.html" title="Index"><link rel="index" href="ix02.html" title="Index of deprecated symbols"><link rel="index" href="ix03.html" title="Index of new symbols in 2.2"><link rel="index" href="ix04.html" title="Index of new symbols in 2.4"><link rel="index" href="ix05.html" title="Index of new symbols in 2.6"><link rel="index" href="ix06.html" title="Index of new symbols in 2.8"><link rel="index" href="ix07.html" title="Index of new symbols in 2.10"><link rel="index" href="ix08.html" title="Index of new symbols in 2.12"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="gtk.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="gtk.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td><td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td><th width="100%" align="center">GTK+ Reference Manual</th><td><a accesskey="n" href="gtk-compiling.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr></table><div class="refentry" lang="en"><a name="gtk-building"></a><div class="titlepage"></div><div class="refnamediv"><table width="100%"><tr><td valign="top"><h2><span class="refentrytitle">Compiling the GTK+ libraries</span></h2><p>Compiling the GTK+ Libraries — How to compile GTK+ itself</p></td><td valign="top" align="right"></td></tr></table></div><div class="refsect1" lang="en"><a name="overview"></a><h2>Building GTK+ on UNIX-like systems</h2><p> This chapter covers building and installing GTK+ on UNIX and UNIX-like systems such as Linux. Compiling GTK+ on Microsoft Windows is different in detail and somewhat more difficult to get going since the necessary tools aren't included with the operating system. </p><p> Before we get into the details of how to compile GTK+, we should mention that in many cases, binary packages of GTK+ prebuilt for your operating system will be available, either from your operating system vendor or from independent sources. If such a set of packages is available, installing it will get you programming wih GTK+ much faster than building it yourself. In fact, you may well already have GTK+ installed on your system already. </p><p> On UNIX-like systems GTK+ uses the standard GNU build system, using <span class="application">autoconf</span> for package configuration and resolving portability issues, <span class="application">automake</span> for building makefiles that comply with the GNU Coding Standards, and <span class="application">libtool</span> for building shared libraries on multiple platforms. </p><p> If you are building GTK+ from the distributed source packages, then won't need these tools installed; the necessary pieces of the tools are already included in the source packages. But it's useful to know a bit about how packages that use these tools work. A source package is distributed as a <code class="literal">tar.gz</code> or <code class="literal">tar.bz2</code> file which you unpack into a directory full of the source files as follows: </p><pre class="programlisting"> tar xvfz gtk+-2.0.0.tar.gz tar xvfj gtk+-2.0.0.tar.bz2 </pre><p> In the toplevel of the directory that is created, there will be a shell script called <code class="filename">configure</code> which you then run to take the template makefiles called <code class="filename">Makefile.in</code> in the package and create makefiles customized for your operating system. The <code class="filename">configure</code> script can be passed various command line arguments to determine how the package is built and installed. The most commonly useful argument is the <code class="systemitem">--prefix</code> argument which determines where the package is installed. To install a package in <code class="filename">/opt/gtk</code> you would run configure as: </p><pre class="programlisting"> ./configure --prefix=/opt/gtk </pre><p> A full list of options can be found by running <code class="filename">configure</code> with the <code class="systemitem">--help</code> argument. In general, the defaults are right and should be trusted. After you've run <code class="filename">configure</code>, you then run the <span class="command"><strong>make</strong></span> command to build the package and install it. </p><pre class="programlisting"> make make install </pre><p> If you don't have permission to write to the directory you are installing in, you may have to change to root temporarily before running <code class="literal">make install</code>. Also, if you are installing in a system directory, on some systems (such as Linux), you will need to run <span class="command"><strong>ldconfig</strong></span> after <code class="literal">make install</code> so that the newly installed libraries will be found. </p><p> Several environment variables are useful to pass to set before running configure. <code class="envar">CPPFLAGS</code> contains options to pass to the C compiler, and is used to tell the compiler where to look for include files. The <code class="envar">LDFLAGS</code> variable is used in a similar fashion for the linker. Finally the <code class="envar">PKG_CONFIG_PATH</code> environment variable contains a search path that <span class="command"><strong>pkg-config</strong></span> (see below) uses when looking for for file describing how to compile programs using different libraries. If you were installing GTK+ and it's dependencies into <code class="filename">/opt/gtk</code>, you might want to set these variables as: </p><pre class="programlisting"> CPPFLAGS="-I/opt/gtk/include" LDFLAGS="-L/opt/gtk/lib" PKG_CONFIG_PATH="/opt/gtk/lib/pkgconfig" export CPPFLAGS LDFLAGS PKG_CONFIG_PATH </pre><p> You may also need to set the <code class="envar">LD_LIBRARY_PATH</code> environment variable so the systems dynamic linker can find the newly installed libraries, and the <code class="envar">PATH</code> environment program so that utility binaries installed by the various libraries will be found. </p><pre class="programlisting"> LD_LIBRARY_PATH="/opt/gtk/lib" PATH="/opt/gtk/bin:$PATH" export LD_LIBRARY_PATH PATH </pre></div><div class="refsect1" lang="en"><a name="dependencies"></a><h2>Dependencies</h2><p> Before you can compile the GTK+ widget toolkit, you need to have various other tools and libraries installed on your system. The two tools needed during the build process (as differentiated from the tools used in when creating GTK+ mentioned above such as <span class="application">autoconf</span>) are <span class="command"><strong>pkg-config</strong></span> and GNU make. </p><div class="itemizedlist"><ul type="disc"><li><p> <a class="ulink" href="http://www.freedesktop.org/software/pkgconfig" target="_top">pkg-config</a> is a tool for tracking the compilation flags needed for libraries that are used by the GTK+ libraries. (For each library, a small <code class="literal">.pc</code> text file is installed in a standard location that contains the compilation flags needed for that library along with version number information.) The version of <span class="command"><strong>pkg-config</strong></span> needed to build GTK+ is mirrored in the <code class="filename">dependencies</code> directory on the <a class="ulink" href="ftp://ftp.gtk.org/pub/gtk/" target="_top">GTK+ FTP site.</a> </p></li><li><p> The GTK+ makefiles will mostly work with different versions of <span class="command"><strong>make</strong></span>, however, there tends to be a few incompatibilities, so the GTK+ team recommends installing <a class="ulink" href="http://www.gnu.org/software/make" target="_top">GNU make</a> if you don't already have it on your system and using it. (It may be called <span class="command"><strong>gmake</strong></span> rather than <span class="command"><strong>make</strong></span>.) </p></li></ul></div><p> Three of the libraries that GTK+ depends on are maintained by by the GTK+ team: GLib, Pango, and ATK. Other libraries are maintained separately. </p><div class="itemizedlist"><ul type="disc"><li><p> The GLib library provides core non-graphical functionality such as high level data types, Unicode manipulation, and an object and type system to C programs. It is available from the <a class="ulink" href="ftp://ftp.gtk.org/pub/gtk/v2.6/" target="_top">GTK+ FTP site.</a> </p></li><li><p> <a class="ulink" href="http://www.pango.org" target="_top">Pango</a> is a library for internationalized text handling. It is available from
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -