# AOT compiling using PackageCompiler

**URL:** <https://discourse.julialang.org/t/aot-compiling-using-packagecompiler/16911>\
**Category:** New to Julia\
**Created:** [October 29, 2018, 5:24am UTC](https://discourse.julialang.org/t/aot-compiling-using-packagecompiler/16911 "2018-10-29T05:24:23Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)\
**Post date:** [October 29, 2018, 1:08pm UTC](https://discourse.julialang.org/t/aot-compiling-using-packagecompiler/16911/5 "2018-10-29T13:08:10Z")

</div>

I find correctly initializing it is a bit tricky. But it works for me:

```python
from pathlib import Path
import ctypes

libpath = Path( __file__ ).resolve().parent.joinpath("builddir", "test.so")
dll = ctypes.CDLL(libpath, ctypes.RTLD_GLOBAL)
dll.func0.restype = ctypes.c_double
dll.func1.restype = ctypes.c_double

try:
    jl_init_with_image = dll.jl_init_with_image
except AttributeError:
    jl_init_with_image = dll.jl_init_with_image__threading
jl_init_with_image.argtypes = [ctypes.c_char_p, ctypes.c_char_p]

if __name__ == " __main__":
    jl_init_with_image(None, str(libpath).encode("utf-8"))
    print("func1 =", dll.func1())
    print("func0 =", dll.func0())

```

---

_[View the full topic](https://discourse.julialang.org/t/aot-compiling-using-packagecompiler/16911)._
