Meet C++/WinRT 2.0: Fewer Dependencies

I’ve always loved tools like Sysinternals where there is a single executable that you can simply copy onto your dev box and run. No need for an installer or a carefully managed tree of DLLs. It just works. Well cppwinrt.exe is like that as well. From the start, you could simply copy it onto any Windows 10 machine and it would just work. Still, there’s always room for improvement. Have a look at the dependencies reported by dumpbin for version 1 of cppwinrt:

> dumpbin /dependents cppwinrt.exe

ADVAPI32.dll
SHELL32.dll
api-ms-win-core-file-l1-1-0.dll
api-ms-win-core-processthreads-l1-1-0.dll
XmlLite.dll
api-ms-win-core-libraryloader-l1-2-0.dll
api-ms-win-core-processenvironment-l1-1-0.dll
RoMetadata.dll
SHLWAPI.dll
KERNEL32.dll
api-ms-win-core-rtlsupport-l1-1-0.dll
api-ms-win-core-heap-l1-1-0.dll
api-ms-win-core-localization-l1-2-0.dll
api-ms-win-core-timezone-l1-1-0.dll
api-ms-win-core-console-l1-1-0.dll
OLEAUT32.dll
api-ms-win-core-winrt-error-l1-1-0.dll
api-ms-win-core-winrt-error-l1-1-1.dll
api-ms-win-core-winrt-l1-1-0.dll
api-ms-win-core-winrt-string-l1-1-0.dll
api-ms-win-core-synch-l1-1-0.dll
api-ms-win-core-threadpool-l1-2-0.dll
api-ms-win-core-com-l1-1-0.dll
api-ms-win-core-com-l1-1-1.dll
api-ms-win-core-synch-l1-2-0.dll

In my defense, that’s not as bad as it looks. All of those DLLs are shipped with Windows 10 and those api-ms-win-core-xxx entries are really forwarding DLLs that support API sets. Still, there was one DLL in that list that caused a bit of trouble. RoMetadata.dll provides the implementation of the metadata parser shipped with the operating system. This is the implementation that practically everyone uses either directly or indirectly. We first hit a snag with this because the rather locked down server SKU that the build engineers at Microsoft wanted to use didn’t include this DLL. That turned out to be a Windows setup bug, but it got me thinking more about dependencies.

With C++/WinRT 2.0 I finally started writing a completely independent metadata parser in standard C++ to avoid this dependency and solve all kinds of trouble with this clunky old parser. A few guys on the team chipped in and this parser is now the foundation for all of our modern tooling. I then also ditched the forwarding DLLs to the point where dumpbin now reports a slightly smaller set of dependencies for version 2 of cppwinrt:

> dumpbin /dependents cppwinrt.exe

KERNEL32.dll
ADVAPI32.dll
XmlLite.dll
SHLWAPI.dll

The fun thing about this is that all of those DLLs are available, not only on Windows 10, but all the way down to Windows 7 and even Windows Vista. That means if you happen to have some crazy old build server running Windows 7, well then you can still run cppwinrt to generate the C++ headers for your project. And if you actually want to run C++/WinRT on Windows 7 you can even do that with a bit of work as well.

And that’s all for today. I hope you enjoy using C++/WinRT!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s