Skip to content

How to compile the ST to a lib and then call it from Rust #1232

Answered by ghaith
jiguorui asked this question in Q&A
Discussion options

You must be logged in to vote

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 using plc --shared file.st -o file.so Make sure to read our documentation at https://plc-lang.github.io/rusty
To 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…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jiguorui
Comment options

Answer selected by jiguorui
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants