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

question
package
windows
ccall
embedding

#1

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) 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

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?
Thanks


#2

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.


#3

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

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 I found this section “Stand-alone Usage”. Maybe this is the way, some idea or another way ?


#4

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

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.


#5

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