WinMain Without C++/CX


  • Hi,

    I am working on creating a WinRT port of an open-sourced, C/C++ framework that helps others port certain kinds of apps (games, by and large) to different platforms.  I'm currently setting up a few, different ways for its users to set up build environments for their apps.  One of my concerns has been forcing C++/CX on the framework's users, and as such, I'm trying to make sure that any code that needs to be directly included in someone's app doesn't need C++/CX, including the file that contains the app's 'main' function.  Using information taken from a few MSDN articles, including the forum post [here], I've been able to piece together a WinMain function that works (insofar that the app runs, and will pass through the latest set of Windows Store / Windows RT Certification Kit tests), however, when I try building a new app using the same files and build settings, Visual C++ gives me an error with a code, "APPX0702".  For example:

    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\AppxPackage\Microsoft.AppXPackage.Targets(926,9): error APPX0702: Payload file 'C:\Users\David\Documents\Code\SDL\SDLSkeleton3\Debug\SDLSkeleton3\SDLSkeleton3.winmd' does not exist.

    If I enable C++/CX in any one of the app's source files (via the /ZW compiler flag), the error doesn't come up and the build succeeds.  The .winmd file in question only seems to get generated when at least one of the app's .cpp files uses C++/CX. 

    Is there any way to get Visual C++'s build tools to generate a .winmd file for an app that doesn't use C++/CX anywhere?


    -- David Ludwig

    Sunday, September 22, 2013 2:20 AM

All replies

  • I don't believe so.  This feature is embedded heavily in the design of these apps.  See: http://blogs.msdn.com/b/vcblog/archive/2011/10/20/10228473.aspx

    Jeff Sanders (MSFT)

    @jsandersrocks - Windows Store Developer Solutions @WSDevSol
    Getting Started With Windows Azure Mobile Services development? Click here
    Getting Started With Windows Phone or Store app development? Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

    Monday, September 23, 2013 6:40 PM
  • Assuming the app doesn't use C++/CX, but does use WRL to implement whatever components are needed (for WinRT to function), might there be other ways to generate a Windows Metadata file for an app, or otherwise make sure the app can build and run?

    My concern lies primarily with a few things:

    1. The /ZW flag can't be used to compile plain C code (cl.exe will fail when attempting to do so), so for many projects, this option can't be enabled per-target.  The library in question, LibSDL, has a lot of projects that use plain C code.

    2. With some build config systems (namely automake), setting up per-file compiler options isn't always as straight-forward as it is in the Visual C++ IDE.  (Many projects that use this library have build systems that use the Visual C++ compiler, but not the IDE.)  It's not to say that it would be impossible (hopefully), just hackish and non-obvious.

    • Edited by DavidLudwig Tuesday, September 24, 2013 7:05 PM
    Tuesday, September 24, 2013 6:24 PM