Generating JuliaC libraries on Windows

Hi all,
I have been trying to use the new JuliaC capabilities in 1.12 (currently on 1.12.5). I have been able to compile executable binaries with some success, however I haven’t been able to successfully compile C callable code into usable libraries. Since the documentation doesn’t provide a thorough example or tutorial, I’ve tried following Jeff Bezanson’s example code shown in this presentation from a few months ago. However… this simply fails without throwing an error and as far as I can tell, nothing is produced. As an example, when I input into the windows terminal:

julia path\to\JuliaCPackage\JuliaC.jl TinyLibm --output-lib tinylibm --compile--ccallable --trim

As I mentioned before when I run this command, nothing happens. I’m not sure if I’m pointing to the JuliaC scripts incorrectly or if it’s saving the output somewhere unknown to me, but the command simply returns to the prompt with no messages.

The other thing I’ve tried out is pointing to the non package juliac folder in the actual Julia installation:

julia Julia-1.12.5\share\julia\Juliac.jl TinyLibm --output-lib tinylibm --compile--ccallable --trim

This sort of works, but I get an error saying I need to be in experimental mode. After fiddling around a bit, I can get this to produce something.

julia Julia-1.12.5\share\julia\Juliac.jl src\TinyLibm.jl --output-lib tinylibm --compile--ccallable --experimental --trim

I do indeed produce a a single tinylib.dll in the directory where I ran the compilation. However, when I try to follow Jeff’s example and use the bundle command to generate a julia callable library, it simply fails. I end up with this error:

Unexpected argument `--bundle`

So that’s pretty much where I’m at. I feel like I’m completely missing something on how to run this properly on Windows. Does anybody have any similarly simply libraries that work on Windows with a bit more detailed instructions?

1 Like

Your best shot is probably WSL. Even if you get it to work, all the people that can provide support will also be on linux.

Maybe try JuliaC API instead of command line? Sorry if it does not turn helpful. I only used API and I could make .exe files normally on Windows for private packages.

Take note that from tutorial following option is not valid since 0.2.3 onward (should be string or just drop it from spec if default):
rpath = nothing,

It could be that recent updates broke older examples as they broke current API example from readme.md.

Thanks for this advice - this was the correct approach. I had to make some minor modification to the API that is included in the ReadMe but I was eventually able to get a library with callable functions from Python.
Here are the basic steps that I took:

In the ImageRecipe struct I changed the output type to “–output-lib”. The file variable in image recipe pointed towards the module folder with the src folder, project toml, and manifest toml. I also changed the add_ccallables input to true.

In the LinkRecipe I changed the rpath to “nothing”.

This allowed the script to run without errors, compile my functions and output the DLL library. As for calling the variables from Python, I used the function described in this presentation in place of the sin/cos functions from Jeff’s example. Then, as outlined in that presentation, I was able to call the compiled Julia function from Python and compare the default numpy function speeds to the compiled Julia speeds (Julia was faster).

6 Likes