166 Incorporation of C-Functions as CoDeSys Library WAGO-I/O-SYSTEM 750758-874/000-131 WAGO-I/O-IPC-C6ManualVersion 1.0.0#include unsigned short MyTestFunction(unsigned short value){return value+=2;}Pos: 46.18 /Serie 758 (Funk, IPC und PFC)/Feldbuskommunikation/C-Funktionen als CoDeSys-Bibliothek @ 10\mod_1312527555987_21.doc @ 75970 @ 123333323332 @ 113 Incorporation of C-Functions as CoDeSysLibraryFor the use of any C- or also Linux functions in CoDeSys, the import interfacedescribed in the following is available. This can be used to load and use Linuxlibraries dynamically into the CoDeSys runtime system.13.1 Example for Linking a Dynamic LibraryThe following section will explain to you by means of an example the procedurefor linking a dynamic library using a C-function in CoDeSys.13.1.1 Developing and Compiling a Linux Shared LibraryBefore you can use C functions within a CoDeSys program, you must develop andcompile a Linux shared library. Proceed in the following manner:1. Create a file with the necessary functions. In this example, the file"libmytest.c" was created for this purpose with a "MyTestFunction"function and "unsigned short" data types.Figure 92: "libmytest.c" file2. Compile and link the file by entering the following command in the Linuxconsole:gcc libmytest.c -Wall -shared -o libmytest.soIn Linux, the parameter "-shared" must be used when calling up the "gcc"compiler.With an error-free compilation of the file, a dynamic library "libmytest.so" isgenerated with the parameter "-shared" that contains the "MyTestFunction" C-function.File name of the Linux librariesThe file name of the Linux libraries must begin with lib.