# Runtime for Julia static compilation with package LightXML - ccall()

**URL:** <https://discourse.julialang.org/t/runtime-for-julia-static-compilation-with-package-lightxml-ccall/3085>\
**Category:** Internals & Design\
**Tags:** question, package, windows, ccall, embedding\
**Created:** [April 6, 2017, 9:42am UTC](https://discourse.julialang.org/t/runtime-for-julia-static-compilation-with-package-lightxml-ccall/3085 "2017-04-06T09:42:12Z")\
**Posts on this page:** 5\
**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:** [April 6, 2017, 9:42am UTC](https://discourse.julialang.org/t/runtime-for-julia-static-compilation-with-package-lightxml-ccall/3085/1 "2017-04-06T09:42:12Z")

</div>

I static compiled my own package `Foo` with using `LightXML` and I have got libFOO.dll. Further, I designed wrapper in C++ ( [Calling Julia Functions](http://docs.julialang.org/en/stable/manual/embedding/#calling-julia-functions)) with the help of `julia.h` and created executable application `foo.exe` for runtime. Now I want to run this application on other PC, but I got error

```julia
C:/Users/windows7/Desktop/CompilePrototype>
ERROR: could not load library "C:\Users\martin\.julia\v0.5\WinRPM\deps\usr\x86_64-w64-mingw32\sys-root\mingw\bin\libxml2-2"
The specified module could not be found.

 in LightXML.XMLDocument() at C:\Users\martin\.julia\v0.5\LightXML\src\document.jl:51
 in writeModelXML at C:\Users\martin\.julia\v0.5\Foo\src\xml\writeModel.jl:32 [inlined]
 in train(::String, ::String, ::String) at C:\Users\martin\.julia\v0.5\Foo\src\Train.jl:77
 in jl_tim_train(::String) at c:\Users\martin\Develop\Julia-0.5.0\share\julia\base\userimg.jl:12

```

Line 51 in `document.jl` is  
`ptr = ccall((:xmlNewDoc,libxml2), Xptr, (Cstring,), "1.0")`

If I created this path `"C:\Users\martin\.julia\v0.5\WinRPM\deps\usr\x86_64-w64-mingw32\sys-root\mingw\bin\"` and copy `libxml2-2.dll` to this path runtime application works.

How may be specified this path to be in the same directory with `foo.exe` or how setup [System Image Building](http://docs.julialang.org/en/stable/devdocs/sysimg/)?  
Thanks

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [April 6, 2017, 9:59am UTC](https://discourse.julialang.org/t/runtime-for-julia-static-compilation-with-package-lightxml-ccall/3085/2 "2017-04-06T09:59:49Z")

</div>

Based on a similar problem I’ve had but without checking the specifics of this package, I expect that you have a file `.julia/v0.5/LightXML/deps/deps.jl`, where WinRPM has hardcoded the path for the libxml2 library on your system. Try changing this to something that works for your use case.

---

<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:** [April 6, 2017, 12:20pm UTC](https://discourse.julialang.org/t/runtime-for-julia-static-compilation-with-package-lightxml-ccall/3085/3 "2017-04-06T12:20:36Z")

</div>

Yes, this file have name `.julia/v0.5/LightXML/deps/build.jl` and contains the source code.

```julia
using Compat
if is_windows()
    using WinRPM
    WinRPM.install("libxml2-2", yes=true)
end

```

But function `WinRPM.install()` has no parameter to select path. Correct me if I’m wrong. In [README.md](https://github.com/JuliaPackaging/WinRPM.jl) I found this section **“Stand-alone Usage”**. Maybe this is the way, some idea or another way ?

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [April 6, 2017, 2:29pm UTC](https://discourse.julialang.org/t/runtime-for-julia-static-compilation-with-package-lightxml-ccall/3085/4 "2017-04-06T14:29:16Z")

</div>

That’s not the file I was thinking of but it turns out that the package I previously dealt with did things differently. For LightXML the path seems to be defined in `LightXML/src/LightXML.jl` with

```julia
if is_windows()
    const libxml2 = Pkg.dir("WinRPM","deps","usr","$(Sys.ARCH)-w64-mingw32","sys-root","mingw","bin","libxml2-2")
else

```

It should be possible to change that to something that works better for your scenario.

---

<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:** [April 7, 2017, 5:09am UTC](https://discourse.julialang.org/t/runtime-for-julia-static-compilation-with-package-lightxml-ccall/3085/5 "2017-04-07T05:09:43Z")

</div>

Thanks @GunnarFarneback , I also found this part of the code 🙂
