# Static julia compilation with own package

**URL:** https://discourse.julialang.org/t/static-julia-compilation-with-own-package/1435
**Category:** Internals & Design
**Tags:** question
**Created:** [January 12, 2017, 2:16pm UTC](https://discourse.julialang.org/t/static-julia-compilation-with-own-package/1435 "2017-01-12T14:16:25Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Martin\_Florek](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@Martin\_Florek](https://discourse.julialang.org/u/Martin_Florek)
#### Post date: [January 12, 2017, 2:16pm UTC](https://discourse.julialang.org/t/static-julia-compilation-with-own-package/1435/1 "2017-01-12T14:16:25Z")

</div>

I tried to compile Julie with my own package “FOO” with the help of script. I ran it with the following command line arguments.

> julia.exe “C:/Julia-0.5.0/build\_sysimg.jl” libBar core2 “C:/Julia-0.5.0/userimg.jl” --force

My userimg.jl looked like

```julia
using FOO

@Base.ccallable Float64 function jl_foo_fcn(vec1::Vector{Float64}, vec2::Vector{Float64})

	return FOO.mape(vec1, vec2)
end

@Base.ccallable Int64 function jl_foo_model(cestaT::String, cestaR::String, pathC::String)

  FOO.model(cestaT, cestaR, pathC)
  return 0
end

```

After compilation I can not open the final libBar.dll in C with the help of julia.h. I get error in function **jl\_init\_with\_image()**

Unhandled exception at 0x0000000064F3C4BA (libjulia.dll) in TIM.exe: 0xC00000FD: Stack overflow (parameters: 0x0000000000000001, 0x000000FEC0D33FF8).

How correct setup commands for compilation?  
If I ran Julia from folder “JULIA\_HOME/bin” with command

> julia.exe -J libBar.dll --compile=no --precompiled=yes

it works with functions from userimg.jl.  
But, how I should compile DLL which contains my package and was executable separately?

Thanks in advance,  
Martin

---

<div class="post-metadata">

### Author: ![ihnorton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihnorton/32/26_2.png) [@ihnorton](https://discourse.julialang.org/u/ihnorton)
#### Post date: [January 14, 2017, 4:13pm UTC](https://discourse.julialang.org/t/static-julia-compilation-with-own-package/1435/2 "2017-01-14T16:13:19Z")

</div>

Please provide a minimal, complete, reproducible example. We cannot help without more information: your C code, which compiler and arguments, etc. Try building the example in `examples/embedding.c`, and make sure that your initialization code works on the default sysimg.

---

<div class="post-metadata">

### Author: ![Martin\_Florek](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@Martin\_Florek](https://discourse.julialang.org/u/Martin_Florek)
#### Post date: [May 24, 2017, 8:51am UTC](https://discourse.julialang.org/t/static-julia-compilation-with-own-package/1435/3 "2017-05-24T08:51:21Z")

</div>

@ihnorton I finally prepared a reproducible example on [How correct open and close Julia DLL in C++?](https://discourse.julialang.org/t/how-correct-open-and-close-julia-dll/3877)

---

<div class="post-metadata">

### Author: ![viralbshah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/viralbshah/32/54_2.png) [@viralbshah](https://discourse.julialang.org/u/viralbshah)
#### Post date: [September 3, 2017, 1:53am UTC](https://discourse.julialang.org/t/static-julia-compilation-with-own-package/1435/4 "2017-09-03T01:53:38Z")

</div>

Some of the new work described here might help, and may be worth revisiting this issue again, if still open.

> [@Compiling and building binaries from your julia code](https://discourse.julialang.org/t/compiling-and-building-binaries-from-your-julia-code/5687/3):
>
> We should probably link here from some of the many older threads where people asked for static compilation.
