Next: , Previous: Building sources using Automake, Up: Preparation


2.4 Initializing the library

Before the library can be used, it must initialize itself. This is achieved by invoking the function gcry_check_version described below.

Also, it is often desirable to check that the version of Libgcrypt used is indeed one which fits all requirements. Even with binary compatibility, new features may have been introduced, but due to problem with the dynamic linker an old version may actually be used. So you may want to check that the version is okay right after program startup.

— Function: const char *gcry_check_version (const char *req_version)

The function gcry_check_version initializes the sub-systems used by Libgcrypt and must be invoked before any other function in the library, with the exception of the GCRYCTL_SET_THREAD_CBS command (called via the gcry_control function), see See Multi-Threading.

Furthermore, this function returns the version number of the library. It can also verify that the version number is higher than a certain required version number req_version, if this value is not a null pointer.