Outputs of JuliaC compiled functions question

I’ve been experimenting with the new JuliaC functionality for generating small binaries introduced in 1.12. I have been able to successfully compile and run example programs (such as the ones provided in this repo). However, I’ve noticed that in all the examples I’ve seen so far, the ultimate output for these functions is just to print statements to the console and returning the Int 0 to indicate that the program ran successfully. I guess my question is: How do we actually get these functions to return something usable? For example, if another programming language (i.e. Matlab, python, etc) needed to call this binary, how would one set it up to return the result of some calculation?

This is probably a really basic question, but I haven’t been able to find anything specific in the documentation, any specific examples, and my fiddling around with existing examples has just returned errors.

1 Like

The most basic answer is that the binary would read its input from stdin and write its output to stdout, and it’s the callers responsibility to hook those up.

This is a good thread, if you are looking to build a shared library callable from other tools rather than a separate process executable: Creating fully self-contained and pre-compiled library

PackageCompiler may still be your best option, depending on what your code needs at runtime.