Skip to content

Commit f70842e

Browse files
authored
Fix Windows DLL lookup: search both oqs.dll and liboqs.dll (Issue #108) (#117)
Signed-off-by: RiqueVaz <[email protected]>
1 parent 5a9d34b commit f70842e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

oqs/oqs.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,11 @@ def _load_shared_obj(
109109
if platform.system() == "Darwin":
110110
paths.append(path.absolute() / Path(f"lib{name}").with_suffix(".dylib"))
111111
elif platform.system() == "Windows":
112-
paths.append(path.absolute() / Path(name).with_suffix(".dll"))
113-
# Does not work
114-
# os.environ["PATH"] += os.path.abspath(path)
112+
# Try both oqs.dll and liboqs.dll in the install path
113+
for dll_name in (name, f"lib{name}"):
114+
paths.append(
115+
path.absolute() / Path(dll_name).with_suffix(".dll")
116+
)
115117
else: # Linux/FreeBSD/UNIX
116118
paths.append(path.absolute() / Path(f"lib{name}").with_suffix(".so"))
117119
# https://stackoverflow.com/questions/856116/changing-ld-library-path-at-runtime-for-ctypes
@@ -281,7 +283,7 @@ def native() -> ct.CDLL:
281283

282284

283285
def oqs_version() -> str:
284-
"""`liboqs` version string."""
286+
"""liboqs version string."""
285287
native().OQS_version.restype = ct.c_char_p
286288
return ct.c_char_p(native().OQS_version()).value.decode("UTF-8") # type: ignore[union-attr]
287289

0 commit comments

Comments
 (0)