Sorry, it's complaining about the ccall,not the cglobal. I has this code inside of init.
ccall((:pari_init, "$pkgdir/local/lib/libpari"), Void, (Int, Int), 3000000000, 10000) It looks like it is complaining about the string interpolation. I guess it needs to know the exact string at compile time as a constant, but it can't know $pkgdir (which is set earlier) until runtime. Or something. Bill. On 18 September 2015 at 13:14, Bill Hart <goodwillh...@googlemail.com> wrote: > Hi, > > I'm actually trying to precompile our library. This seems to necessitate > putting some of the initialisation code we had in an __init__ function. > > But I'm having problems with the cglobal syntax. > > According to the documentation, it takes a tuple with exactly the same > format as ccall. > > But this works inside __init__: > > ccall((:pari_init, "$pkgdir/local/lib/libpari"), Void, (Int, Int), > 3000000000, 10000) > > But this does not: > > global avma = cglobal((:avma, "$pkgdir/local/lib/libpari"), Ptr{Ptr{Int}}) > > The complaint is below. Can someone help me? > > Note that if I change that string to just :libpari, it complains that > libpari is not found. This is despite me dlopen'ing libpari earlier in > __init__. > > I have also set Libdl.DL_LOAD_PATH (I am on Linux) in __init__. > > This all works fine if I put the code outside of __init__, but then I > can't precompile. As soon as I put it inside __init__, it no longer seems > to work. > > Bill. > > ERROR: LoadError: InitError: TypeError: __init__: in ccall: first argument > not a pointer or valid constant expression, expected Ptr{T}, got > Tuple{Symbol,ASCIIString} > in __init__ at /home/wbhart/.julia/v0.4/Nemo/src/Nemo.jl:61 > in _require_from_serialized at loading.jl:84 > in require at ./loading.jl:218 > in include at ./boot.jl:260 > in include_from_node1 at ./loading.jl:271 > in process_options at ./client.jl:308 > in _start at ./client.jl:411 > during initialization of module Nemo > while loading /home/wbhart/.julia/v0.4/Nemo/test/runtests.jl, in > expression starting on line 1 > ================================[ ERROR: Nemo > ]================================= > > failed process: Process(`/home/wbhart/julia/usr/bin/julia > --check-bounds=yes --code-coverage=none --color=yes > /home/wbhart/.julia/v0.4/Nemo/test/runtests.jl`, ProcessExited(1)) [1] > > > ================================================================================ > ERROR: Nemo had test errors > in error at ./error.jl:21 > in test at pkg/entry.jl:753 > in anonymous at pkg/dir.jl:31 > in cd at file.jl:22 > in cd at pkg/dir.jl:31 > in test at pkg.jl:71 > >