On Tuesday, 20 August 2019 at 17:17:01 UTC, Vladimirs Nordholm wrote:
In code I have `import core.sys.windows.winuser;`, but still get this error.

Importing only specifies that you expect the symbols to be there, it doesn't mean the functions are linked in.

On Windows there are three targets, 32-bit OMF (old dmd default), 32-bit MSCoff and 64-bit MSCoff (dub defaults to MSCoff since not too long ago). While DMD ships with import libraries for all targets, I never know which ones get linked in by default and which ones don't.

Usually when I get Windows linking errors I either switch the target (the OMF import libraries are sometimes lacking, so then I compile with --arch=x86_mscoff or --arch=x86_64) or explicitly link the import libraries.
Just quickly Google a function like GetSystemMetrics:
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsystemmetrics
On the bottom it says "Library: User32.lib" so I add `pragma(lib, "User32.lib");` to my module using it.

Reply via email to