Add a directory to DLL search path for Windows.
Say you are building a library, library_name
, which loads some 3rd party shared libraries from
code:priv_dir(library_name)/lib
. It's quite easy to add rpath on *nix systems, but we don't really have rpath in Windows.
Therefore, we have to use AddDllDirectory
to manually add the directory that contains these
.dll files to the search path.
:ok =
case os:type() of
{win32, nt} -> dll_loader_helper_beam:add_dll_directory("/SOME/DIRECTORY")
_ -> ok
end
Note that calling dll_loader_helper_beam:add_dll_directory/1
on *nix systems will NOT have any effect, and ok
will be returned.
If available in Hex, the package can be installed
by adding dll_loader_helper_beam
to your list of dependencies:
{deps, [
dll_loader_helper_beam
]}.
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/dll_loader_helper_beam.