--- title: "Initialize the library" url: "https://docs.adyen.com/point-of-sale/classic-library-deprecation/classic-library-integrations/c-library-integration/key-steps-c-library/initialize-the-library-c-library" source_url: "https://docs.adyen.com/point-of-sale/classic-library-deprecation/classic-library-integrations/c-library-integration/key-steps-c-library/initialize-the-library-c-library.md" canonical: "https://docs.adyen.com/point-of-sale/classic-library-deprecation/classic-library-integrations/c-library-integration/key-steps-c-library/initialize-the-library-c-library" last_modified: "2026-05-23T12:56:20+02:00" language: "en" --- # Initialize the library [View source](/point-of-sale/classic-library-deprecation/classic-library-integrations/c-library-integration/key-steps-c-library/initialize-the-library-c-library.md) Before the library can be used, you must initialize it with the `init_library` function. The call and the callback are asynchronous to prevent the call from blocking the calling thread. ## Implement the callback Implement the `initialization_CB` and pass this as a parameter of the `init_library` call. For more information on how to do this, see [Implement callbacks](/point-of-sale/classic-library-deprecation/classic-library-integrations/c-library-integration/calls-and-callbacks-c-library/implement-callbacks). ### Parameters | Name | Description | | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `result` | Returns the result of initializing the library. The result of initialization is always zero. | | `echo_struct` | A pointer to a user-defined struct that is echoed back in the callback. Use this to share a POS data struct between the call to the library and the callback from the library. | ### Code example ```cpp void initialization_CB(void *result, void *echo_struct){app_context_t * POS = (app_context_t *)echo_struct; printf("library is initialized"); } ``` ## Allocate request structure Use `init_library_allocate` to allocate memory for an `init_library_request` structure. Populate the `init_library_request` by performing string duplication to fill heap-allocated strings.  The library automatically frees this memory. ## Call the init\_library function Call the `init_library` function with the provided parameters to initialize the library. ### Parameters | Name | Type | Required | Description | | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `initReq` | Struct: [init\_library\_request](/point-of-sale/classic-library-deprecation/classic-library-integrations/c-library-integration/structs/init_library_request) | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | A pointer to the `init_library_request` struct, this struct contains all the input parameters for this call. Allocate this request with init\_library\_allocate. | | `initialization_CB` | Function | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | A pointer to the callback function in the POS that the system returns with the results of the initialization call. | | `echo_struct` | Struct: [echo\_struct](/point-of-sale/classic-library-deprecation/classic-library-integrations/c-library-integration/structs/echo_struct) | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | A pointer to a POS-defined struct that is echoed back in the callback. Use this to share a POS data struct between the call to the library and the callback from the library. | ## Get the function call result `ADYLibraryResult` is used to store the result of the function call, the immediate response to the call. This is an enum that indicates if the system received the request. Should be `ADYEN_OK`, if this is not the case, something has gone wrong. In this case, check the input to the call and if it cannot be resolved, log the result and contact [Support Team](https://ca-test.adyen.com/ca/ca/contactUs/support.shtml?form=other) This is not the final result of the call. The library returns the final result in response to the library initialization call. ## Handle the callback The POS needs to wait for the initialization callback before continuing with other functions, like boarding the POS systems and PED devices, and performing transactions. ### Parameters | Name | Description | | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `result` | Returns the result of initializing the library. The result of initialization is always zero. | | `echo_struct` | A pointer to a user-defined struct that is echoed back in the callback. Use this to share a POS data struct between the call to the library and the callback from the library. | ## Code example ```cpp typedef struct { char *user_data; } app_context_t; // result is always null for initialization callback void initialization_CB(void *result, void *echo_struct) { app_context_t * POS = (app_context_t *)echo_struct; printf("library is initialized"); } main() { app_context_t POS; init_library_request *initReq = init_library_allocate(); initReq->pos_name = strdup("Adyen"); initReq->app_name = strdup("Adyen"); . . . ADYLibraryResult result = init_library(initReq, initialization_CB, &POS); } ```