![]() |
![]() |
![]() |
GNetwork Library Manual | ![]() |
---|
Compiling GNetwork ApplicationsCompiling GNetwork Applications — How to compile applications which use GNetwork |
The first order of business is getting your application or library to link to the GNetwork library. This section assumes that your system has pkg-config installed.
PkgConfig provides a means of including the proper compiling and linking flags for your application. It has macros for use in an autoconf/automake system as well as a basic command-line tool (pkg-config) for use in a basic Makefile. The command-line tool can be used to include the compiling and linking flags needed for an application which uses GNetwork:
$ cc `pkg-config --cflags libgnetwork-1.0` -c main.c -o main.o $ cc `pkg-config --libs libgnetwork-1.0` -o appname main.o
However, since most applications which use GNetwork will also use the
autoconf/automake build system, using the autoconf macro inside
configure.in
makes more sense:
... PKG_CHECK_MODULES(NETWORKING, libgnetwork-1.0 >= 1.0.0) AC_SUBST(NETWORKING_CFLAGS) AC_SUBST(NETWORKING_LIBS) ...
Then, in your source directory's Makefile.am:
... target_CFLAGS = \ $(NETWORKING_CFLAGS) target_LIBS = \ $(NETWORKING_LIBS) ...
That's it, that will automatically read and include the appropriate information needed to compile a program which uses GNetwork.