Use PLC project as referenced library
![]() | Available from TwinCAT 3.1 Build 4026 |
As of Build 4026, you can reference PLC projects in other PLC projects of the same TwinCAT project as a library. As a result you do not have to install a library project to test it. This makes library development easier and more efficient.
Reference PLC project as library
In order to be able to reference a PLC project in another PLC project as a library, both projects must be contained in the same solution. To do this, you can create new PLC projects or add an existing library project or source library as a PLC project. It does not matter whether the PLC projects are located in the same TwinCAT project, in different TwinCAT projects, or are stand-alone PLC projects.
- A solution with at least two PLC projects is open.
- 1. Enter a title, a version number and a company name in the project properties of the first PLC project (library project). Optionally, you can also fill in the remaining fields.
- 2. Check the box next to Allow referencing the project as library
- 3. Save the modifications.
- The PLC project can now be referenced as a library.
- 4. In the second PLC project, open the dialog Add library via the Library Manager or the context menu of the object References in the PLC project tree.
- The PLC project referenced as a library is marked with square brackets. It can be selected like the installed libraries and added to the project via OK.
Use projects referenced as library
- Projects that are referenced as libraries can basically be used like included source libraries.
- Run the command Go To Definition for objects from the referenced project and use the Cross Reference List.
- Debug your project and step through the programming blocks using breakpoints.
- The peculiarity of projects referenced as a library, compared to installed libraries, is that you can change the programming more easily. If you open an object from the referenced project via the Library Manager, with a command such as Go To Definition or when debugging, then the object opens in the referenced project. There you can edit it directly.
- Programming changes are immediately available in the project that uses the project referenced as library.
- You can reference multiple projects as library at the same time.
- You can reference a project as library where another project is already referenced.
- You can use the referenced version and the installed library of a project at the same time. Note that you must use a unique namespace to distinguish between them.
Change library reference
- You can save as library and install a project that is referenced as a library. If other projects are referenced in the project, the placeholders are automatically changed to placeholders for installed libraries.
- You can use the context menu to switch between the installed library and the project referenced as a library:
- When changing the reference, note that the library information (title, version, and company) must match.
