Next: , Previous: , Up: GNU Gnulib   [Contents][Index]

7 Building the ISO C and POSIX Substitutes

This section shows a radically different way to use Gnulib.

You can extract the ISO C / POSIX substitutes part of gnulib by running the command

gnulib-tool --create-testdir --source-base=lib \
            --dir=/tmp/posixlib `posix-modules`

The command ‘posix-modules’ is found in the same directory as gnulib-tool.

The resulting directory can be built on a particular platform, independently of the program being ported. Then you can configure and build any program, by setting CPPFLAGS and LDFLAGS at configure time accordingly: set CPPFLAGS="-I.../posixlib/lib", plus any essential type definitions and flags that you find in .../posixlib/config.h, and set LDFLAGS=".../posixlib/lib/libgnu.a".

This way of using Gnulib is useful when you don’t want to modify the program’s source code, or when the program uses a mix between C and C++ sources (requiring separate builds of the posixlib for the C compiler and for the C++ compiler).