NHDaly / ApplicationBuilder.jl

[deprecated] Compile, bundle, and release julia software
MIT License
168 stars 15 forks source link

Relative linkage path prevents run script from any directory except "core" #29

Closed VPetukhov closed 6 years ago

VPetukhov commented 6 years ago

Hi,

I'm trying to build an app, which depends on RMath package. Building script is the following:

using ApplicationBuilder
using Rmath
import SpecialFunctions

lib_deps = [Rmath.libRmath, SpecialFunctions.openspecfun, SpecialFunctions.openspecfun * ".1.3",
            "/lib64/libgfortran.so.4", "/lib64/libgfortran.so.4.0.0"];

build_app_bundle("segment_data.jl", appname="Segmentation", libraries=lib_deps);

Is creates "builddir/Segmentation/" folder, which contains "core", "res" and "lib" folders. "lib" directory contains "libRmath-julia.so" library and several others.

When I run script from "core" folder, it works well. Though, if I change path (e.g. calling it from "builddir" with ./core/segment_data command), I get error:

fatal: error thrown and no exception handler available.
InitError(mod=:Rmath, error=ErrorException("could not load library "../lib/libRmath-julia.so"
../lib/libRmath-julia.so: cannot open shared object file: No such file or directory"))
rec_backtrace at /julia/src/stackwalk.c:94
record_backtrace at /julia/src/task.c:246
jl_throw at /julia/src/task.c:577
jl_errorf at /julia/src/rtutils.c:77
jl_dlerror at /julia/src/dlload.c:74 [inlined]
jl_load_dynamic_library_ at /julia/src/dlload.c:196
jl_get_library at /julia/src/runtime_ccall.cpp:48
jl_get_library at /julia/src/runtime_ccall.cpp:56 [inlined]
jl_load_and_lookup at /julia/src/runtime_ccall.cpp:59
__init__ at /home/vp/.julia/packages/Rmath/Py9gH/src/Rmath.jl:47
jfptr___init___27581 at /d0-mendel/home/viktor_petukhov/spatial/SpatialRNA/src/builddir/Segmentation/core/segment_data.so (unknown line)
jl_apply_generic at /julia/src/gf.c:2182
jl_apply at /julia/src/julia.h:1538 [inlined]
jl_module_run_initializer at /julia/src/toplevel.c:90
_julia_init at /julia/src/init.c:820
julia_init__threading at /julia/src/task.c:302
main at ./core/segment_data (unknown line)
__libc_start_main at /build/eglibc-SvCtMH/eglibc-2.19/csu/libc-start.c:287
_start at ./core/segment_data (unknown line)
VPetukhov commented 6 years ago

Found error in my "segment_data.jl" script. There I used code:

Core.eval(Rmath, :(libRmath = "../lib/libRmath-julia.so"))

But correct way was to use

Core.eval(Rmath, :(libRmath = "libRmath-julia.so"))

And to add "builddir/Segmentation/lib" to LD_LIBRARY_PATH (on both building machine and machine when I run the compiled package).

NHDaly commented 5 years ago

Thanks for sharing the solution!!

It looks like you're running on Linux, right? Has that solution worked for you? If so, we should add it to documentation somewhere.

VPetukhov commented 5 years ago

@NHDaly ,

Yes, it's linux (Centos 7), and it works well.