Skip to content
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

Is it possible to link d2d1 statically on Windows? #443

Open
ngugcx opened this issue Apr 26, 2021 · 10 comments
Open

Is it possible to link d2d1 statically on Windows? #443

ngugcx opened this issue Apr 26, 2021 · 10 comments

Comments

@ngugcx
Copy link

ngugcx commented Apr 26, 2021

I want to build a single file app with druid on Windows.
But druid depends on direct2d, d2d1.dll is dynamically linked.

@raphlinus
Copy link
Contributor

It's getting that DLL from the system, it's not bundled with the executable. Is there a specific problem you're trying to solve here?

@ngugcx
Copy link
Author

ngugcx commented Apr 26, 2021

@raphlinus , I built my app(based on druid) on Windows 10 with "-C target-feature=+crt-static".
It failed to run on Windows 7 because of missing d2d1.dll and api-ms-win-core-libraryloader-l1-2-0.dll.
I have no idea why it needs api-ms-win-core-libraryloader-l1-2-0.dll. I can't find it even on my Windows 10 system, there is only api-ms-win-core-libraryloader-l1-1-0.dll, that's weird.

I wonder if linking d2d1 statically will solve the problem.

@raphlinus
Copy link
Contributor

I don't understand all subtleties in linking and packaging. To be honest, when testing on Windows 7 I always build on Windows 7, but I definitely see the value in being able to distribute a binary that can run across multiple versions.

From what I do understand, it seems unlikely that statically linking would solve the problem. I can't imagine that a version of d2d1 for Windows 10 would work on Windows 7, and can imagine other problems.

@ngugcx
Copy link
Author

ngugcx commented Apr 26, 2021

I made a mistake, there IS a d2d1.dll shipped with Windows 7 system.
My app fails with:

C:\tests>.\flex.exe
�[2mApr 26 11:55:17.566�[0m �[32m INFO�[0m druid_shell::platform::windows::util:
 No shcore.dll
�[2mApr 26 11:55:17.566�[0m �[32m INFO�[0m druid_shell::platform::windows::util:
 Could not load `GetDpiForSystem`. Windows 10 or later is needed
�[2mApr 26 11:55:17.566�[0m �[32m INFO�[0m druid_shell::platform::windows::util:
 Could not load `GetDpiForWindow`. Windows 10 or later is needed
�[2mApr 26 11:55:17.566�[0m �[32m INFO�[0m druid_shell::platform::windows::util:
 Could not load `SetProcessDpiAwarenessContext`. Windows 10 or later is needed
�[2mApr 26 11:55:17.566�[0m �[32m INFO�[0m druid_shell::platform::windows::util:
 Could not load `GetSystemMetricsForDpi`. Windows 10 or later is needed
�[2mApr 26 11:55:17.566�[0m �[32m INFO�[0m druid_shell::platform::windows::util:
 No dcomp.dll
�[2mApr 26 11:55:17.582�[0m �[34mDEBUG�[0m druid::localization: available locale
s [], current en-US
�[2mApr 26 11:55:17.582�[0m �[34mDEBUG�[0m druid::localization: resolved: [en-US
]
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: hresult
80004002', druid-shell\src\platform\windows\window.rs:1303:48

image

I may need to open an issue for druid.

@raphlinus
Copy link
Contributor

raphlinus commented Apr 26, 2021

Hmm, odd for that function to be failing (it's D2D1CreateFactory - here's where it's being called). Does this crash if compiled on the Windows 7 machine, or only when compiled on Windows 10 and the executable is run on Windows 7.

The error code is E_NOINTERFACE, which is odd. One thing to try is removing the D2D1_DEBUG_LEVEL_INFORMATION, as suggested in this StackOverflow question.

@ngugcx
Copy link
Author

ngugcx commented Apr 26, 2021

My Windows 7 box doesn't have a good network, I can't setup the rust build tools there.
Where is D2D1_DEBUG_LEVEL_INFORMATION set? I can't find it in the code.

@jrmuizel
Copy link
Contributor

Does your Windows 7 box have the platform update applied? https://www.microsoft.com/en-ca/download/details.aspx?id=36805

@ngugcx
Copy link
Author

ngugcx commented Apr 26, 2021

@jrmuizel , the update fixes the problem.
Is it possible to get rid of this dependence?

@raphlinus
Copy link
Contributor

raphlinus commented Apr 26, 2021

No, we've chosen platform update as the minimum compatibility level for piet and druid. Being compatible with earlier versions would require significant compromise, which we do not think is worth it given that it is pretty far out of date.

I think this issue can be closed?

@ngugcx
Copy link
Author

ngugcx commented Apr 26, 2021

This should be documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants