I’m working on a C++ package (called MParT) for MacOS and Linux, as well as creating bindings to it in Julia. So far, I’ve had moderate success, where I can use Linux to ]add https://github.com/MeasureTransport/MParT.jl (the Julia-side bindings) and Julia downloads the appropriate tarball from MParT_jll published via Yggdrasil. However, when someone tries to do the same on a MacOS device, MParT fails to precompile, saying
ERROR: LoadError: could not load library "libmpartjl"
dlopen(libmpartjl.dylib, 1): image not found
...
which is bizarre, because if you look in the tarball provided at MParT_jll, which looks correct (it provides the correct dylib files in the correct directories). Any help would be greatly appreciated!!
Shouldn’t you be referring to the library as libmpartjl (a symbol exported by MParT_jll — this is a constant string containing the full path of the library) rather than by the string "libmpartjl"?
Just to be clear, are you suggesting using the macro wrapmodules as
@wrapmodules libmpartjl
? The git repo seems to use those interchangably in its examples/readme, but that might be it. I’ll edit and mark as solution once things get merged if this solves it.
For the record, after @stevengj 's proposed solution, the same issue is still there when precompiling. Here’s a full error log
[ Info: Precompiling MParT [4383ffe1-dc98-4547-9515-b1eacdbc2dac]
ERROR: LoadError: UndefVarError: libmpartjl not defined
Stacktrace:
[1] top-level scope
@ ~/opt/anaconda3/envs/mpart/share/julia/packages/MParT/1POGA/src/MParT.jl:18
[2] include
@ ./Base.jl:418 [inlined]
[3] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
@ Base ./loading.jl:1318
[4] top-level scope
@ none:1
[5] eval
@ ./boot.jl:373 [inlined]
[6] eval(x::Expr)
@ Base.MainInclude ./client.jl:453
[7] top-level scope
@ none:1
in expression starting at ~/opt/anaconda3/envs/mpart/share/julia/packages/MParT/1POGA/src/MParT.jl:2
ERROR: Failed to precompile MParT [4383ffe1-dc98-4547-9515-b1eacdbc2dac] to ~/opt/anaconda3/envs/mpart/share/julia/compiled/v1.7/MParT/jl_nSRJS0.
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, ignore_loaded_modules::Bool)
@ Base ./loading.jl:1466
[3] compilecache(pkg::Base.PkgId, path::String)
@ Base ./loading.jl:1410
[4] _require(pkg::Base.PkgId)
@ Base ./loading.jl:1120
[5] require(uuidkey::Base.PkgId)
@ Base ./loading.jl:1013
[6] require(into::Module, mod::Symbol)
@ Base ./loading.jl:997
Something to note that I just found-- I’m loading multiple modules from the same library, and this is not able to find the library for the second module I want to wrap, i.e. the second time I load the library there is an error. It seems like if I comment that out and only load one module from the library, everything works okay.