Skip to main content

Basic Principle of Library Management

In CODESYS 4, libraries are referenced, not permanently embedded in the application.

The references originate from different sources: from the input of the developer, from device descriptions, and from the programming system itself. Many of these references are vague. They designate a placeholder or a version pattern, but this does not name a specific library.

The compiler, however, requires a unique version for each library. Because of this, two things are separated in CODESYS 4: the desired references and the unique libraries identified from them.

Basic principle: Reference list and lockfile

Library management is based on two files.

The Libraries.json is the reference list. This is where you enter the direct library references. The file describes which libraries the application requires. It is maintained by hand or in the user interface. 

The entire dependency graph is established from the reference list during library resolution. Each reference is resolved recursively when this is done. The libraries which are themselves required by referenced libraries are also determined.

The result is written to the Libraries.lock.json lockfile.

File

Role

Libraries.json

Reference list with the desired libraries

The file is managed and maintained by the developer.

Libraries.lock.json

Lockfile containing the resolved dependency graph

The file is automatically created and updated during library resolution.

Benefits for version control and reproducibility

The lockfile is designed for reproducibility. Its keys are sorted, the format remains stable, and a SHA384 checksum is stored for compiled libraries.

This makes the lockfile appropriate for version control systems such as Git or SVN. The file is a readable JSON format. Changes to the library state can be tracked in the diff and checked in the code review.

When the lockfile is checked in with the project, every developer gets the same library state.

Tip

Anyone familiar with npm or NuGet will recognize the principle of the lockfile. This prior knowledge is not required for working with CODESYS 4.