libsoup Reference Manual |
---|
Compiling with libsoupCompiling with libsoup — Notes on compiling |
Like other GNOME libraries, libsoup uses
pkg-config to provide compiler options. The
package name is "libsoup-2.4
". So in your
configure
script, you might specify something like:
PKG_CHECK_MODULES(LIBSOUP, [libsoup-2.4 >= 2.26]) AC_SUBST(LIBSOUP_CFLAGS) AC_SUBST(LIBSOUP_LIBS)
The "2.4
" in the package name is the "API version"
(indicating "the version of the libsoup API
that first appeared in version 2.4") and is essentially just part of
the package name.
If you are using any of the GNOME-specific features of
libsoup (such as automatic proxy
configuration), you must require
"libsoup-gnome-2.4
" instead:
PKG_CHECK_MODULES(LIBSOUP, [libsoup-gnome-2.4 >= 2.26]) AC_SUBST(LIBSOUP_CFLAGS) AC_SUBST(LIBSOUP_LIBS)
You can also make libsoup-gnome an optional dependency:
PKG_CHECK_MODULES(LIBSOUP_GNOME, [libsoup-gnome-2.4 >= 2.26], [LIBSOUP_CFLAGS="$LIBSOUP_GNOME_CFLAGS" LIBSOUP_LIBS="$LIBSOUP_GNOME_LIBS" AC_DEFINE(HAVE_LIBSOUP_GNOME, 1, [Have libsoup-gnome])], [PKG_CHECK_MODULES(LIBSOUP, [libsoup-2.4 >= 2.26])]) AC_SUBST(LIBSOUP_CFLAGS) AC_SUBST(LIBSOUP_LIBS)
This will allow the application to be built with either plain
libsoup or with
libsoup-gnome, and it will define the C
preprocessor symbol HAVE_LIBSOUP_GNOME
if
libsoup-gnome features are available.
Code using libsoup should do:
#include <libsoup/libsoup.h>
or, for libsoup-gnome:
#include <libsoup/libsoup-gnome.h>
Including individual headers besides the two main header files is not
recommended. You may include both libsoup.h
and
libsoup-gnome.h
(though this is not required; the
latter automatically includes the former).