2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
4 <refentry id="libsoup-build-howto">
6 <refentrytitle>Compiling with libsoup</refentrytitle>
7 <manvolnum>3</manvolnum>
8 <refmiscinfo>LIBSOUP Library</refmiscinfo>
12 <refname>Compiling with libsoup</refname><refpurpose>Notes on compiling</refpurpose>
16 <title>Using pkg-config</title>
19 Like other GNOME libraries, <application>libsoup</application> uses
20 <application>pkg-config</application> to provide compiler options. The
21 package name is "<literal>libsoup-2.4</literal>". So in your
22 <literal>configure</literal> script, you might specify something like:
25 <informalexample><programlisting>
26 PKG_CHECK_MODULES(LIBSOUP, [libsoup-2.4 >= 2.26])
27 AC_SUBST(LIBSOUP_CFLAGS)
28 AC_SUBST(LIBSOUP_LIBS)
29 </programlisting></informalexample>
32 The "<literal>2.4</literal>" in the package name is the "API version"
33 (indicating "the version of the <application>libsoup</application> API
34 that first appeared in version 2.4") and is essentially just part of
39 If you are using any of the GNOME-specific features of
40 <application>libsoup</application> (such as automatic proxy
41 configuration), you must require
42 "<literal>libsoup-gnome-2.4</literal>" instead:
45 <informalexample><programlisting>
46 PKG_CHECK_MODULES(LIBSOUP, [libsoup-gnome-2.4 >= 2.26])
47 AC_SUBST(LIBSOUP_CFLAGS)
48 AC_SUBST(LIBSOUP_LIBS)
49 </programlisting></informalexample>
52 You can also make <application>libsoup-gnome</application> an optional
56 <informalexample><programlisting>
57 PKG_CHECK_MODULES(LIBSOUP_GNOME,
58 [libsoup-gnome-2.4 >= 2.26],
59 [LIBSOUP_CFLAGS="$LIBSOUP_GNOME_CFLAGS"
60 LIBSOUP_LIBS="$LIBSOUP_GNOME_LIBS"
61 AC_DEFINE(HAVE_LIBSOUP_GNOME, 1, [Have libsoup-gnome])],
62 [PKG_CHECK_MODULES(LIBSOUP, [libsoup-2.4 >= 2.26])])
63 AC_SUBST(LIBSOUP_CFLAGS)
64 AC_SUBST(LIBSOUP_LIBS)
65 </programlisting></informalexample>
68 This will allow the application to be built with either plain
69 <application>libsoup</application> or with
70 <application>libsoup-gnome</application>, and it will define the C
71 preprocessor symbol <literal>HAVE_LIBSOUP_GNOME</literal> if
72 <application>libsoup-gnome</application> features are available.
78 <title>Headers</title>
81 Code using <application>libsoup</application> should do:
84 <informalexample><programlisting>
85 #include <libsoup/soup.h>
86 </programlisting></informalexample>
89 or, for <application>libsoup-gnome</application>:
92 <informalexample><programlisting>
93 #include <libsoup/soup-gnome.h>
94 </programlisting></informalexample>
97 Including individual headers besides the two main header files is not
98 recommended. You may include both <literal>soup.h</literal> and
99 <literal>soup-gnome.h</literal> (though this is not required; the
100 latter automatically includes the former).