Skip to content

Commit 09bd043

Browse files
authored
šŸ Fix dynamic loading of QDMI device DLLs on Windows when an absolute path is provided (#1720)
## Description This fixes an oversight in #1694 that broke dynamic QDMI library loading on Windows and was discovered in iqm-finland/QDMI-on-IQM#63 If an absolute path is provided, the implementation now falls back to the previously-working one that used the simpler `LoadLibraryW` for loading the DLL. I'll to a test run of this PR in the QDMI-on-IQM repo before we merge and release. AI (Claude Code) was used to diagnose the issue and come up with potential solutions. The actual solution was implemented manually. ## Checklist <!--- This checklist serves as a reminder of a couple of things that ensure your pull request will be merged swiftly. --> - [x] The pull request only contains commits that are focused and relevant to this change. - [x] I have added appropriate tests that cover the new/changed functionality. - [x] I have updated the documentation to reflect these changes. - [x] I have added entries to the changelog for any noteworthy additions, changes, fixes, or removals. - [x] I have added migration instructions to the upgrade guide (if needed). - [x] The changes follow the project's style guidelines and introduce no new warnings. - [x] The changes are fully tested and pass the CI checks. - [x] I have reviewed my own code changes. **If PR contains AI-assisted content:** - [x] I have disclosed the use of AI tools in the PR description as per our [AI Usage Guidelines](https://github.com/munich-quantum-toolkit/core/blob/main/docs/ai_usage.md). - [x] AI-assisted commits include an `Assisted-by: [Model Name] via [Tool Name]` footer. - [x] I confirm that I have personally reviewed and understood all AI-generated content, and accept full responsibility for it. Signed-off-by: Lukas Burgholzer <burgholzer@me.com>
1 parent cd87146 commit 09bd043

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

ā€ŽCHANGELOG.mdā€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ This project adheres to [Semantic Versioning], with the exception that minor rel
2525
- ā¬†ļø Require LLVM 22.1 for C++ library builds ([#1549]) ([**@burgholzer**], [**@denialhaag**])
2626
- šŸ“¦ Build MLIR by default for C++ library builds ([#1356]) ([**@burgholzer**], [**@denialhaag**])
2727

28+
### Fixed
29+
30+
- šŸ Fix dynamic loading of QDMI device DLLs on Windows when an absolute path is provided ([#1720]) ([**@burgholzer**])
31+
2832
### Removed
2933

3034
- šŸ”„ Remove the density matrix support from the MQT Core DD package ([#1466]) ([**@burgholzer**])
@@ -389,6 +393,7 @@ _šŸ“š Refer to the [GitHub Release Notes](https://github.com/munich-quantum-tool
389393

390394
<!-- PR links -->
391395

396+
[#1720]: https://github.com/munich-quantum-toolkit/core/pull/1720
392397
[#1719]: https://github.com/munich-quantum-toolkit/core/pull/1719
393398
[#1709]: https://github.com/munich-quantum-toolkit/core/pull/1709
394399
[#1702]: https://github.com/munich-quantum-toolkit/core/pull/1702

ā€Žsrc/qdmi/driver/Driver.cppā€Ž

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,14 @@ namespace {
7474
[[nodiscard]] auto loadDeviceLibrary(const std::string& libName) -> HMODULE {
7575
const auto requested = std::filesystem::path(libName);
7676

77-
const std::filesystem::path path = requested.has_parent_path()
78-
? requested
79-
: getDriverDirectory() / requested;
77+
if (requested.has_parent_path()) {
78+
// A directory component was supplied: Directly load the library.
79+
return LoadLibraryW(requested.wstring().c_str());
80+
}
8081

82+
// Bare filename: resolve relative to the driver's own directory so that
83+
// builtin device DLLs installed next to the driver are found reliably.
84+
const auto path = getDriverDirectory() / requested;
8185
return LoadLibraryExW(path.wstring().c_str(), nullptr,
8286
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR |
8387
LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);

0 commit comments

Comments
Ā (0)