Hi all!

I have a package which depends a external binary library(I will just write 
dll from now on), I want to figure out a way to call the dll in a way that 
if some user decides to precompile a system image with this library it can 
still work.

My package is Xpress.jl (I know it wraps commercial lib), my initial link 
to the binary was very simple, actually a copied from Gurobi.jl.
It uses the a build step to locate an environment variable, than it creates 
a script that defines a const global variable (for the pkg) that indicates 
the dll directory.

This method would have a few problems:
1 - will not support complete precompilation since it relies on creating an 
extra .jl file
2 - the user must have the environment variable, so that its bad for 
shipping the complete precompiled julia with the dll inside

I was able to hack the library to do that (since I wrote most of it), I 
removed the build step, I loaded the pkg without loading the dll, just 
loaded the dll afterwards, using 'dlopen'. (The shipped program sent the 
path of the dll via args to the a julia code, thats how I used dlopen)

As it was not enough the pkg also currently has a __init__() function, that 
call a environment initializer of the dll. (For the precompiled version I 
removed it and loaded the environment just after dlopen)

Clearly I hacked the package a lot, so I would like to know if there is any 
other way to do something similar.

In a nutshell, I would like a method that
1- enables the user to precompile the pkg into sysimg
2- enables the pkg to reach to the dll even in sysimg precompilation 
state,for me there is no problem in having to put the dll inside some julia 
installation folder

Thanks in advance!

Reply via email to