Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 9f53138a531066fad3ff013246a3463c > files > 299

gtk2-devel-docs-2.24.4-1.fc15.i686.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Compiling Hello World</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="GTK+ 2.0 Tutorial"
HREF="book1.html"><LINK
REL="UP"
TITLE="Getting Started"
HREF="c39.html"><LINK
REL="PREVIOUS"
TITLE="Getting Started"
HREF="c39.html"><LINK
REL="NEXT"
TITLE="Theory of Signals and Callbacks"
HREF="x159.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>GTK+ 2.0 Tutorial</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="c39.html"
ACCESSKEY="P"
>&#60;&#60;&#60; Previous</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Getting Started</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x159.html"
ACCESSKEY="N"
>Next &#62;&#62;&#62;</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="SEC-COMPILING"
>Compiling Hello World</A
></H1
><P
>To compile use:</P
><P
><P
CLASS="LITERALLAYOUT"
><TT
CLASS="LITERAL"
>gcc -Wall -g helloworld.c -o helloworld `pkg-config --cflags gtk+-2.0` \</TT
><br>
<TT
CLASS="LITERAL"
>    `pkg-config --libs gtk+-2.0`</TT
></P
></P
><P
>This uses the program <TT
CLASS="LITERAL"
>pkg-config</TT
>, which can be obtained from
<A
HREF="http://www.freedesktop.org"
TARGET="_top"
>www.freedesktop.org</A
>. This program 
reads the <TT
CLASS="FILENAME"
>.pc</TT
> which comes with GTK to determine what 
compiler switches are needed to compile programs that use GTK. 
<TT
CLASS="LITERAL"
>pkg-config --cflags gtk+-2.0</TT
> will output a list of include
directories for the compiler to look in, and 
<TT
CLASS="LITERAL"
>pkg-config --libs gtk+-2.0</TT
>
will output the list of libraries for the compiler to link with and
the directories to find them in. In the above example they could have
been combined into a single instance, such as
<TT
CLASS="LITERAL"
>pkg-config --cflags --libs gtk+-2.0</TT
>.</P
><P
>Note that the type of single quote used in the compile command above
is significant.</P
><P
>The libraries that are usually linked in are:</P
><P
></P
><UL
><LI
><P
>The GTK library (<TT
CLASS="LITERAL"
>-lgtk</TT
>), the widget library, 
based on top of GDK.</P
></LI
><LI
><P
>The GDK library (<TT
CLASS="LITERAL"
>-lgdk</TT
>), the Xlib wrapper.</P
></LI
><LI
><P
>The gdk-pixbuf library (<TT
CLASS="LITERAL"
>-lgdk_pixbuf</TT
>), the image 
manipulation library.</P
></LI
><LI
><P
>The Pango library (<TT
CLASS="LITERAL"
>-lpango</TT
>) for internationalized 
text.</P
></LI
><LI
><P
>The gobject library (<TT
CLASS="LITERAL"
>-lgobject</TT
>), containing the
type system on which GTK is based.</P
></LI
><LI
><P
>The gmodule library (<TT
CLASS="LITERAL"
>-lgmodule</TT
>), which is used 
to load run time extensions.</P
></LI
><LI
><P
>The GLib library (<TT
CLASS="LITERAL"
>-lglib</TT
>), containing miscellaneous
functions; only g_print() is used in this particular example. GTK is built on top
of GLib so you will always require this library. See the section on
<A
HREF="c2023.html"
>GLib</A
> for details.</P
></LI
><LI
><P
>The Xlib library (<TT
CLASS="LITERAL"
>-lX11</TT
>) which is used by GDK.</P
></LI
><LI
><P
>The Xext library (<TT
CLASS="LITERAL"
>-lXext</TT
>). This contains code 
for shared memory pixmaps and other X extensions.</P
></LI
><LI
><P
>The math library (<TT
CLASS="LITERAL"
>-lm</TT
>). This is used by GTK 
for various purposes.</P
></LI
></UL
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="c39.html"
ACCESSKEY="P"
>&#60;&#60;&#60; Previous</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="book1.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="x159.html"
ACCESSKEY="N"
>Next &#62;&#62;&#62;</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Getting Started</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="c39.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Theory of Signals and Callbacks</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>