Environments:
- Apple M3
- MacOS 26.3.1
- Julia 1.12.6
- PackageCompiler v2.3.0
Now create_library seems to set @executable_path for MacOS, but the libraries are not always in the executable path in many use cases.
% otool -l /***/julia/libmolgraphjl/lib/libmolgraphjl.dylib | grep LC_RPATH -A2
cmd LC_RPATH
cmdsize 32
path @executable_path (offset 12)
--
cmd LC_RPATH
cmdsize 40
path @executable_path/julia (offset 12)
I'm working on Python projects that internally uses Julia packages as a library, and encounters some linking problems. Possible workarounds are
- Relinking
% install_name_tool -add_rpath /***/julia/libmolgraphjl/lib/julia /***/julia/libmolgraphjl/lib/libmolgraphjl.dylib
but now this can produce an error shown as below.
error: /***/install_name_tool: changing install names or rpaths can't be redone for: /***/julia/libmolgraphjl/lib/libmolgraphjl.dylib (for architecture arm64) because larger updated load commands do not fit (the program must be relinked, and you may need to use -headerpad or -headerpad_max_install_names)
- Environment variables
# in .zprofile
export DYLD_FALLBACK_LIBRARY_PATH=/***/julia/libmolgraphjl/lib:/***/julia/libmolgraphjl/lib/julia
This works well in the default terminal, but DYLD_*** env vars will be ignored in some shell environment (e. g. Jupyter in VSCode)
- Build with
@loader_path
This seems to be the most straightforward solution.
|
function rpath_sysimage() |
|
Sys.iswindows() ? `` : |
|
Sys.isapple() ? `-Wl,-rpath,'@executable_path' -Wl,-rpath,'@executable_path/julia'` : |
|
`-Wl,-rpath,\$ORIGIN:\$ORIGIN/julia` |
|
end |
Temporarily overwriting this function as like below seems to work at least in my environment.
import PackageCompiler
function PackageCompiler.rpath_sysimage()
Sys.iswindows() ? `` :
Sys.isapple() ? `-Wl,-rpath,'@loader_path' -Wl,-rpath,'@loader_path/julia'` :
`-Wl,-rpath,\$ORIGIN:\$ORIGIN/julia`
end
Of course this may affect other sysimage functions, so there should be a specific rpath function for create_library
function rpath_sysimage_library()
Sys.iswindows() ? `` :
Sys.isapple() ? `-Wl,-rpath,'@loader_path' -Wl,-rpath,'@loader_path/julia'` :
`-Wl,-rpath,\$ORIGIN:\$ORIGIN/julia`
end
Environments:
Now
create_libraryseems to set@executable_pathfor MacOS, but the libraries are not always in the executable path in many use cases.I'm working on Python projects that internally uses Julia packages as a library, and encounters some linking problems. Possible workarounds are
but now this can produce an error shown as below.
This works well in the default terminal, but DYLD_*** env vars will be ignored in some shell environment (e. g. Jupyter in VSCode)
@loader_pathThis seems to be the most straightforward solution.
PackageCompiler.jl/src/juliaconfig.jl
Lines 94 to 98 in f34698c
Temporarily overwriting this function as like below seems to work at least in my environment.
Of course this may affect other sysimage functions, so there should be a specific rpath function for
create_library