-
I have some old codes in ST for a PLC platfrom. If I want to compile the codes into a library or something like that, how do I call it from Rust. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello @jiguorui sorry for the late reply. If you have more specific questions feel free to ask here :) |
Beta Was this translation helpful? Give feedback.
Hello @jiguorui sorry for the late reply.
So if you have your PLC code in flat files, you can compile them with the compiler using something similar to the the gcc or rustc command lines.
plc -c file.st -o file.o
which will give you an object file that you can use in another application. You can also create libraries by usingplc --shared file.st -o file.so
Make sure to read our documentation at https://plc-lang.github.io/rustyTo use your library from rust, you need to declare the functions you need as
extern C
functions. We use the C calling conventions on our generated code. In rust you will need to declare such functions as unsafe similar to what you would do with C functions (check t…