2.1. The VAPI File

Check if the library’s development package has installed a pkg-config file (.pc file extension). If so, give your VAPI file the same name. For example libfoo.pc should have the VAPI called libfoo.vapi. This allows the details of the library files to be automatically picked up and passed through to the C compiler and linker.

When developing a VAPI a typical command to build the tests against the binding would be:

valac --vapidir . --pkg libfoo program_using_libfoo.vala

The dot after --vapidir tells valac to include the current directory when looking for VAPI files. The --pkg libfoo switch tells valac to look for a VAPI called libfoo.vapi. Note the the .vapi suffix is dropped. If the VAPI also has the same name as a .pc file then valac will find and use the .pc file to extract the relevant library details to pass to the C compiler and linker.

Example VAPI files can be found in the of the Vala git repository of the Vala git repository. Files stating they have been generated by vapigen have been generated through GObject Introspection and are not examples of manually written bindings.

Once you have a working VAPI file, even if it is only a subset of the library’s functionality, please consider sharing the file. See Vala Extra VAPIs and Why Distribute Bindings Upstream.