-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32 | LOAD_LIBRARY_SEARCH_USER_DIRS for DLL loading on Windows #47775
base: master
Are you sure you want to change the base?
Conversation
The use of For example, julia> @ccall "kernel32".SetDefaultDllDirectories(0x1000::UInt32)::UInt8
0x01
julia> using Random
julia> MersenneTwister(1234)
ERROR: could not load library "libdSFMT"
The parameter is incorrect. This pull request does not use With this pull request, one can recover with julia> @ccall "kernel32".SetDefaultDllDirectories(0x1000::UInt32)::UInt8 # 0x1000 LOAD_LIBRARY_SEARCH_DEFAULT_DIRS
0x01
julia> using Random
julia> MersenneTwister(1234)
ERROR: could not load library "libdSFMT"
The parameter is incorrect.
Stacktrace:
[1] dsfmt_init_by_array
@ C:\Users\kittisopikulm\.julia\juliaup\julia-1.8.3+0.x64\share\julia\stdlib\v1.8\Random\src\DSFMT.jl:69 [inlined]
[2] seed!(r::MersenneTwister, seed::Vector{UInt32})
@ Random C:\Users\kittisopikulm\.julia\juliaup\julia-1.8.3+0.x64\share\julia\stdlib\v1.8\Random\src\RNGs.jl:313
[3] seed!
@ C:\Users\kittisopikulm\.julia\juliaup\julia-1.8.3+0.x64\share\julia\stdlib\v1.8\Random\src\RNGs.jl:321 [inlined]
[4] MersenneTwister(seed::Int64)
@ Random C:\Users\kittisopikulm\.julia\juliaup\julia-1.8.3+0.x64\share\julia\stdlib\v1.8\Random\src\RNGs.jl:113
[5] top-level scope
@ REPL[11]:1
julia> @ccall "kernel32".AddDllDirectory(raw"D:\repos\julia\usr\bin"::Cwstring)::Ptr{Nothing}
Ptr{Nothing} @0x000001b9dc2c5ec0
julia> MersenneTwister(1234)
MersenneTwister(1234) This overall will permit Julia to be embedded in a wider range of applications where |
cc: @vtjnash |
Co-authored-by: Jameson Nash <[email protected]>
Some notes:
|
Currently, we use
LOAD_WITH_ALTERED_SEARCH_PATH
to load DLL libraries on Windows. With this pull request, if loading with the above fails, we useLOAD_LIBRARY_SEARCH_USER_DIRS
.This is a minimalist version of the idea proposed on Discourse. Rather than replacing
LOAD_WITH_ALTERED_SEARCH_PATH
withLOAD_LIBRARY_SEARCH_DEFAULT_DIRS
, we only useLOAD_LIBRARY_SEARCH_USER_DIRS
if loading with ``LOAD_WITH_ALTERED_SEARCH_PATH` fails.This allows the user to manually build a search list of directories via
AddDllDirectory
.https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibraryexw