Can Windows Store applications be built with Mingw?

眉间皱痕 提交于 2019-12-17 18:54:51

问题


Is there a way to build Windows Store applications with the Mingw toolchain? (And ultimately cross compile them from mingw on Linux, since if it works in one Mingw toolchain it should work in another.)

I guess one requirement is to stick to the API:s allowed in the Windows Store app sandbox, but what other things are there to consider before distribution to the store? XAML? 32 or 64 bit code?

Since Mingw C++ is not link compatible with MSVC++, I assume plain C programs without WRL would be the easiest way to achieve this?


回答1:


You would need to use the Windows Runtime C++ Template Library (WRL) directly, you wouldn't be able to use C++/CX as Mingw doesn't support it. Other than that, I think you just need the Windows 8 SDK, then you need to configure Mingw to use the headers and libraries. Also, you won't be able to use XAML to describe your user interface, you'll have to manually create your UI in code.

Rather than attempt to write the entire application with mingw and cross compile it with linux, you can write your core libraries with mingw, then write a simple UI wrapper over the libraries using Visual Studio Express (free). That way you can use all the nice stuff like XAML and ref-counted instances.

This is the approach I have taken - using libraries written in C++, and then a separate UI project (using XAML) which references the other libraries. It works well.




回答2:


MinGW-w64 has experimental support of UWP C runtime distributed with VS2013. C dlls linked with universal VS2013 crt are also can be used with VS2015 and VS2017 UWP toolchains ( UWP project should has "Microsoft Visual C++ 2013 Runtime Package for Windows Universal" as dependency).
MinGW-w64 provides winstorecompat library to replace some forbidden API calls on UWP platform with user defined implementation. winstorecompat should be linked to user's library before linking with system libraries.
Also it's required to build MinGW C dll with custom flag -Wl,--dynamicbase to pass Windows 10 Store Certification Kit security checks and also set appcontainer bit flag to be compatible with Windows 10 Store binary requriements.
Here it's link to sample project I've worked on how to consume plain C MinGW Dll into Windows 10 C# UWP application, PInvoke methods from C dll and pass Certification Kit security checks to be published in Windows Store. I've referenced libVLC WinRT build implementation.




回答3:


Take a look at using C++/WinRT with clang compiler instead of MinGW:

https://github.com/Microsoft/cppwinrt
https://moderncpp.com/

"C++/WinRT is a standard C++ language projection for the Windows Runtime implemented solely in header files. It allows you to both author and consume Windows Runtime APIs using any standards-compliant C++ compiler."

"C++/WinRT relies on C++17 language features and as such you need to tell C++ that your project requires the C++17 language standard."

"While Visual C++ continues to be our primary target, we use Clang as our secondary compiler to ensure standard conformance. Many small changes have been made in this update to support Clang builds and to fix correctness bugs that were only found with Clang builds."



来源:https://stackoverflow.com/questions/12909139/can-windows-store-applications-be-built-with-mingw

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!