dhoegh / BuildExecutable.jl

Build a standalone executables from a Julia script
Other
156 stars 21 forks source link

Bundling julia into the executable build dir #11

Closed rofinn closed 8 years ago

rofinn commented 8 years ago

Sorry to bug you folks again, but would it be possible to give build_executable an option to bundle julia and all its dependencies into the executable for distributing to other machines that don't have julia installed?

For example, if I build my playground script on my host machine and try to transfer the build directory to a vm I get the following error.

$ ./playground
dyld: Library not loaded: @rpath/libjulia.dylib
  Referenced from: /Volumes/Playground.jl/deps/usr/build/./playground
  Reason: image not found
Trace/BPT trap: 5

From what I can tell the julia rpath is hard coded to the machine the executable was built on

otool -l playground
...
Load command 15
            cmd LC_RPATH
       cmdsize 96
           path /Users/rory/.playground/src/julia-0.4_2015-11-30/Contents/Resources/julia/lib/julia (offset 12)
...
dhoegh commented 8 years ago

I do not have a mac could you test if interchanging @executable_path in https://github.com/dhoegh/BuildExecutable.jl/blob/aa248281d766c95161538b6b1f3980c55f58474a/src/BuildExecutable.jl#L179 with @loader_path fixes the problem?

rofinn commented 8 years ago

So, that doesn't fix the problem and produces the same result cause sys.buildfile is always the full path on the host system cause of this line buildpath = abspath(dirname(Libdl.dlpath(debug ? "libjulia-debug" : "libjulia"))). I think the only way to get build_executable to do what I'm thinking is to have it take a flag that tells it to copy the julia build to the executable build directory and changes the buildpath accordingly. If that sounds reasonable I'll try and getting something working on the weekend when I have some time.

dhoegh commented 8 years ago

That sounds reasonable, as BuildExecutable produces a portable executable on windows but not on linux and mac. If you could figure out how to make the mac executable portable that would be greatly appreciated. As it would make the experience across platforms better and it could potentially also lead to a fix on to make the linux executable portable. I have tried briefly to look into the issue on linux, but did not manage.

rofinn commented 8 years ago

Found a fix for OSX. Just needed an extra line to change the @rpath to point to @executable_path rather than the host julia install directory (sys.buildpath).

dhoegh commented 8 years ago

I will close this as i think this is fixed in #14. Please respond if this is not the case.