Below is the reason why calling pari_init needs to go inside the __init__ function when precompiling.
Clearly you can't precompile a call to initialise an external library. You have to that kind of initialisation at module initialisation time. Thus I am fairly certain it does need to go inside the __init__ function. It just seems that the linker behaves differently from within __init__ somehow. Bill. pari_maximal_order_elem.constructors... signal (11): Segmentation fault unsafe_load at pointer.jl:47 jlcall_unsafe_load_24505 at (unknown line) jl_apply_generic at /home/wbhart/julia/usr/bin/../lib/libjulia.so (unknown line) call at /home/wbhart/.julia/v0.4/Nemo/src/pari/PariTypes.jl:179 call at /home/wbhart/.julia/v0.4/Nemo/src/pari/pari_maximal_order_elem.jl:130 jl_apply_generic at /home/wbhart/julia/usr/bin/../lib/libjulia.so (unknown line) test_pari_maximal_order_elem_constructors at /home/wbhart/.julia/v0.4/Nemo/src/../test/pari/pari_maximal_order_elem-test.jl:6 test_rings at /home/wbhart/.julia/v0.4/Nemo/src/../test/Rings-test.jl:46 test_all at /home/wbhart/.julia/v0.4/Nemo/src/../test/Rings-test.jl:58 jlcall_test_all_21287 at (unknown line) jl_apply_generic at /home/wbhart/julia/usr/bin/../lib/libjulia.so (unknown line) unknown function (ip: 0x7f1f470f2e23) unknown function (ip: 0x7f1f470f2241) unknown function (ip: 0x7f1f47106e58) unknown function (ip: 0x7f1f47107b49) jl_load at /home/wbhart/julia/usr/bin/../lib/libjulia.so (unknown line) include at ./boot.jl:260 jl_apply_generic at /home/wbhart/julia/usr/bin/../lib/libjulia.so (unknown line) include_from_node1 at ./loading.jl:271 jl_apply_generic at /home/wbhart/julia/usr/bin/../lib/libjulia.so (unknown line) process_options at ./client.jl:316 _start at ./client.jl:411 unknown function (ip: 0x7f1f444ba3f9) jl_apply_generic at /home/wbhart/julia/usr/bin/../lib/libjulia.so (unknown line) unknown function (ip: 0x401a69) unknown function (ip: 0x40163f) __libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line) unknown function (ip: 0x401685) unknown function (ip: (nil)) On Friday, 18 September 2015 15:22:39 UTC+2, Bill Hart wrote: > > This improved things a bit, though there are some further issues: > > * both __init__ and our test code need to load this file, but the current > directory is different in each case, so I can't give a relative path for > deps/deps.jl itself, which puts us back right where we were. > > (I've resolved this temporarily by loading the file in multiple places > inside and outside of __init__ with a fairly complex set of directory > changes. I had to do the same with loading the libraries themselves.) > > * I was unable to make "/home/wbhart/.julia/v0.4/Nemo/local/lib/libpari" > work in the ccall (when called within __init__). It needs > "/home/wbhart/.julia/v0.4/Nemo/local/lib/libpari.so" > > * The library we actually need to initialise within __init__ (the library > libpari) is being particularly stubborn. I'm able to call the pari_init > function from Nemo.jl from outside of __init__ if I don't precompile. But > if I precompile, this has to go inside __init__ for some reason. But then I > get this: > > ERROR: LoadError: InitError: error compiling __init__: could not load > library "/home/wbhart/.julia/v0.4/Nemo/local/lib/libpari.so" > libgmp.so.16: cannot open shared object file: No such file or directory > > I have checked the file libpari.so really exists. Certainly libgmp.so.16 > exists, and we also put the rpath in the pari library itself (it requires > libgmp) and checked with ldd that it resolves libgmp.so.16. > > wbhart@arithmeticon:~/.julia/v0.4/Nemo/local/lib$ ldd libpari.so > linux-vdso.so.1 => (0x00007fffc0950000) > libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd7489b0000) > /lib64/ld-linux-x86-64.so.2 (0x00007fd749690000) > libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd7486a8000) > libgmp.so.16 => > /home/wbhart/.julia/v0.4/Nemo/local/lib/libgmp.so.16 (0x00007fd748430000) > libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fd748228000) > libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 > (0x00007fd748008000) > > > wbhart@arithmeticon:~/.julia/v0.4/Nemo/local/lib$ ls -l libgmp.so.16 > lrwxrwxrwx 1 wbhart wbhart 16 Sep 18 13:21 libgmp.so.16 -> > libgmp.so.16.0.0 > > So in summary, I can call the pari_init function in libpari from outside > __init__ no problems. But from within it I have all sorts of trouble. > > Any ideas? > > Bill. > > On Friday, 18 September 2015 14:01:48 UTC+2, Steven G. Johnson wrote: >> >> The typical thing is to determine your library path at Pkg.build time, in >> a script in YourPkg/deps/build.jl, and write to a const mylibrary="..." in >> YourPkg/deps/deps.jl which is included by your package. >> >
