microsoft / cppwinrt

C++/WinRT
MIT License
1.67k stars 239 forks source link

CppWinrt /Concept TS/ WSL /GCC6 #242

Closed IkoLogs closed 6 years ago

IkoLogs commented 7 years ago

Hi

Working on Cppwinrt App, and looking to use Concept TS. Only compiler that i know supports is GCC6.

I have WSL installed on my MSVC, is there a wild chance i can use GCC6 to compile CppWinrt project.

Failing that is there anyway to use Concept TS in Winrt Project.

Already tried and getting this error error MSB4044: The "CheckRuntimeLibrary" task was not given a value for the required parameter "RuntimeLibrary".

My main goal is being able to use Concept TS in CppWinrt project, if such is possible cheers.

Cheers

IkoLogs commented 7 years ago

Got a bit further in my research using this thread from Stack Overflow

https://stackoverflow.com/questions/38786014/how-to-compile-executable-for-windows-with-gcc-with-linux-subsystem

Its regard using MingW.

The thread shows how to build for windows x64/x86 using MingW commands, but no command shown for building for Arm.

But mainly need to confirm also if this proposed tool chain will work for CppWinrt.

My life would be much easier when MS adds Concept TS to thier compiler. Any time scales on ms compiler for Concept TS,?

Cheers

kennykerr commented 7 years ago

I have been meaning to test with GCC, but so far have been unable to find the time. We currently test with Visual C++ and Clang. I don't know of any reason that it should not work, but there may well be a few subtle conformance differences between Clang and GCC.

IkoLogs commented 7 years ago

Thank you very much for the clearance signal on that. cheers

IkoLogs commented 7 years ago

Hi

So far i have used cppwinrt sample projects for my Apps, never had luck trying to get any other MSVS project template to work with winrt.

My path to being able to compile with GCC6 is using MSVS WSL and using Linux project template. Add Winrt nuget package to such a project with no code i get error below.

error MSB4044: The "CheckRuntimeLibrary" task was not given a value for the required parameter "RuntimeLibrary".

My plan is to find a way to use Gcc6 from existing winrt project, i like Blocks winrt best cause it compiles for x86/x64/Arm.

So need a way to get Winrt project to allow me to add remote build system project option or something along that line.

cheers

MikeGitb commented 7 years ago

Not exactly sure what you are doing, but in case you are not aware: The Linux project template is designed for compiling on a REMOTE LINUX machine (which can be a local WSL Instance). Although cpp/winrt itself is afaik a header-only library, it obviously depends on the Windows Runtime Library and probably other parts of the windows API that are not available on Linux.

IkoLogs commented 7 years ago

Thanks for the correction, to be clear all am trying to do is compile Winrt with Gcc6 so i have access to ConceptTS. Could you please advice best route to go in order to compile a WinRt sample project using Gcc6 inside MSVS environment.

I have no need for linux except WSL comes with gcc6 to give me an elf i can convert to exe with MinGw, that was my plan assuming winrt is independent c++ header lib, it was a desperate attempt i must admit. I asked the question cause not aware the internal dependencies of winrt, i still dont know the magic behind the project type, so all my apps are based on winrt sample projects.

I have also put this question to MSVS forum, its just a lot busier over there and response is slow, given its a very broad subject forum.

Thanks for the support.

IkoLogs commented 7 years ago

I did a bit more digging on this, looked at VisualGDB commercial tool, but without much info on the tool i suspect the fact that i cant create winrt project from scratch could be an issue when it comes to trying to setup a project with my tool chain of choice.

Got a massive template library based on Winrt that desperately need ConceptTS to add clarity to the code, so any help regards setting up project to use GCC to compile WInrt for x86/x64/Arm very much welcome.

Other option i looked at is MYsys2, am totally new to all this cross platform related stuff, am used to MSVC point and click.

Thanks again

MikeGitb commented 7 years ago

I'm pretty sure that when Kenny is talking about GCC, he means a Version that generates native windows binaries, which would mean one of the gcc's shipped with mingw, msys2 or cygwin. I'm not sure if any of them supports windows on arm, so that requirement of yours might be a Problem.

Looking at the problem from the other side, are you really sure,, concepts are that important for you? For one, what was merged into the c++20 draft afaik significantly differs from what is available in gcc6, so if you adopt concepts now, you have to restrict yourself a lot in order to stay compatible with what might be implemented in msvc and clang.

Also, I found this an interesting read: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0726r0.html. Their Opinion was that concepts are much less useful in practice than people commonly assume (although, that might just be a QoI issue to some degree).

Finally, gcc doesn't support coroutines which are really useful when programming cpp/winrt

jlvandenhout commented 7 years ago

I asked the question cause not aware the internal dependencies of winrt, i still dont know the magic behind the project type, so all my apps are based on winrt sample projects.

Not sure if my comment is going to help in this thread, but I'm certainly interested in your question, since I try to build applications using the C++/WinRT project, and can't even get it to work with Microsoft's own VC++ compiler outside Visual Studio. This helped me to understand the concept of WinRT a little bit more: http://tirania.org/blog/archive/2011/Sep-15.html

As I understand it now, the Windows Runtime API is exposed via .winmd files and the C++/WinRT headers are merely a binding to those .winmd files. So somehow the compiler has to be notified that the headers you use are a binding to those .winmd files, correct?

MikeGitb commented 7 years ago

Actually no. Afaik, you only need the wind files to create the headers (they are already part of the GitHub repository and will be part of the windows sdk in the future, so you shouldn't have to care about that). Once that is done the windows runtime is just another com library.

kennykerr commented 7 years ago

We illustrated this process at CppCon on Friday. The slides and videos should be available shortly for those who were not able to attend in person. Briefly, the cppwinrt.exe compiler converts the metadata inside the .winmd files into C++ header files. At that point you can simply #include the headers and use your C++ compiler and forget about where the headers came from. You no longer need cppwinrt.exe and you no longer need the .winmd files.

IkoLogs commented 7 years ago

Thank you very much for the updates gents. Been away having big fun with getting to know the new VS OpenFolder project type.

This is how I have now brought in GCC via MSYS IntelliSense is not MSVC level of perfection, and or I got more work to do on that, any tips welcome printf builds, but intellsense does not know about Print

But I can now build hello world that has concept TS class in MSVS.

Next step is to try add WInRT.

Please if there are any specific instructions regarding WInRT for MSYS or IntelliSense let me know, example what folders to add to path/include and any essential compiler switches.

Example WinRT Blocks sample uses "/bigobj /await /std:c++latest /d1permissive-" Any of these required or something to add for GCC. other than -fconcepts to include concept TS.

Thanks for the new info and vid, I go digest that.

Thanks for the support

kennykerr commented 7 years ago

The Blocks samples does not require /bigobj, /await or /permissive- as those are optional. It does however require /std:c++latest or simply /std:c++17.

IkoLogs commented 7 years ago

Hi

Thanks for the feedback .

  1. The std:c++17 was required for build

  2. Build went along a bit now stuck on #include <experimental/coroutine>. This from winrt/base.h build output below.

`-- Build started: Project: App, Configuration: ------ In file included from D:\Development\Projects\LIBS\WindowsSdk\10.0.10240.0\shared/minwindef.h:182:0, from D:\Development\Projects\LIBS\WindowsSdk\10.0.10240.0\shared/windef.h:24, from D:\Development\Projects\LIBS\WindowsSdk\10.0.10240.0\um/windows.h:168, from D:\Development\Projects\LIBS\WindowsSdk\10.0.10240.0\shared/rpc.h:20, from C:/dev/msys64/mingw64/x86_64-w64-mingw32/include/inspectable.h:7, from D:\Development\Projects\LIBS\CppWinRT\10.0.15063.0\cppwinrt-master\10.0.15063.0/winrt/base.h:29, from D:\Development\Projects\LIBS\CppWinRT\10.0.15063.0\cppwinrt-master\10.0.15063.0/winrt/Windows.ApplicationModel.Core.h:5, from pch.h:6, from App.cpp:1: D:\Development\Projects\LIBS\WindowsSdk\10.0.10240.0\um\winnt.h(150,2): error GD9D5490A: #error "No Target Architecture"

error "No Target Architecture"

^~~~~

In file included from D:\Development\Projects\LIBS\WindowsSdk\10.0.10240.0\um/winscard.h:30:0, from D:\Development\Projects\LIBS\WindowsSdk\10.0.10240.0\um/windows.h:205, from D:\Development\Projects\LIBS\WindowsSdk\10.0.10240.0\shared/rpc.h:20, from C:/dev/msys64/mingw64/x86_64-w64-mingw32/include/inspectable.h:7, from D:\Development\Projects\LIBS\CppWinRT\10.0.15063.0\cppwinrt-master\10.0.15063.0/winrt/base.h:29, from D:\Development\Projects\LIBS\CppWinRT\10.0.15063.0\cppwinrt-master\10.0.15063.0/winrt/Windows.ApplicationModel.Core.h:5, from pch.h:6, from App.cpp:1: D:\Development\Projects\LIBS\WindowsSdk\10.0.10240.0\um\oaidl.h(473,17): error GF8C50DDC: pasting "/" and "/" does not give a valid preprocessing token _VARIANT_BOOL bool; ^ D:\Development\Projects\LIBS\WindowsSdk\10.0.10240.0\um\oaidl.h(488,17): error GF8C50DDC: pasting "/" and "/" does not give a valid preprocessing token _VARIANT_BOOL *pbool; ^ In file included from D:\Development\Projects\LIBS\CppWinRT\10.0.15063.0\cppwinrt-master\10.0.15063.0/winrt/Windows.ApplicationModel.Core.h:5:0, from pch.h:6, from App.cpp:1: D:\Development\Projects\LIBS\CppWinRT\10.0.15063.0\cppwinrt-master\10.0.15063.0/winrt/base.h:52:10: fatal error: experimental/coroutine: No such file or directory

include <experimental/coroutine>

        ^~~~~~~~~~~~~~~~~~~~~~~~

compilation terminated.

Build failed.`

Thanks

Zingam commented 7 years ago

@IkoLogs It looks like VC++ 15.5 will support Concepts TS: https://blogs.msdn.microsoft.com/vcblog/2017/09/26/16905/ And that might happen before the end of this year.

MikeGitb commented 7 years ago

I believe it when I see it ;)

IkoLogs commented 7 years ago

Hi

copy App.winmdApp.winmd $(OutDir)App.winmd

Any update regards cppcon vids and instructions for getting Winrt to build in vs2017 using gcc. Currently I am able to use msvc and gcc for non winrt code. And concepts are a great improvement to my template interface and SFINAE mess.

Been away updating my code to use concepts in winrt independent area, now need to start accessing winrt API again so any help much appreciated.

Again my current setup is MSVS openfolder project using gcc compiler. the project is working perfectly but no information regards Winrt integration.

line below is in project settings for Blocks, do I need to add this to pre build activity for my gcc tool chain too. Or is this no longer needed regards your recent post on cppcon copy App.winmdApp.winmd $(OutDir)App.winmd

I don't mind those slides you mentioned so I can keep hacking away.

As for concepts on MSVS, thanks for the update on that looking forward to it. Currently I edit in msvc mode cause intellisense is better, build in gcc mode, so in msvs I #define concept struct just so I can have coloured and not white.

So the current solution is not perfect but its great being able to use 2 compilers on my project, gcc is more fussy, msvc lets you focus on putting your ideas down before interruption, gcc wakes you up early from template ideas that just won't work.

Count myself lucky to be working on cross platform project same time as Microsoft is pushing in same area thus OpenFolder, still a command line in the backend, and the more you sort out the right commands in the backend , the more the project solution looks and feels like the MSVS cockpit we used to.

Any help to build Winrt via gcc7.2 much appreciated.

IkoLogs commented 7 years ago

Hello

Just a bump up to say still looking for road map to WinRT using GCC compiler. I am working on cross platform code so building with MSVC, and GCC.

Currently updated to MSVS version 15.5, which was expected to have concept TS, but its not in that version. Need to build with GCC for cross platform needs in general not just Concept TS.

Thanks much, hoping for GCC support and wishing for Concept TS support in MSVS, both will do just fine thank you.

kennykerr commented 7 years ago

Sorry, I've been rather swamped and haven't got around to testing GCC yet. Will post an update when I do.

I haven't been able to find a convenient GCC build environment for Windows. Both VC (naturally) and Clang make it quite straightforward to target a Windows build environment.

IkoLogs commented 7 years ago

Hi

Thanks for the feedback, been busy trying to keep up with my timescales, cross platform development is freedom and hardwork.

MS better update MSVC to include concept TS cause as more people realize its night and day for templates the demand will increase, makes working with templates just as easy to type, maintain as polymorphism. Now i can declare template interface thats all in one place like with abstract class used as interface. But its checked at compile time very powerful for Embedded IoT field which i work in.

I was lucky that MS OPenFolder project type came along when i started cross platform and its working very well using MInGW MYSYS2-GCC with Openfolder.

The main difference between Openfolder and standard VS project solution being project settings are done in text based file, and offers extreme flexibility on what type of project you creating.

The open folderproject type has 2 important files that pretty much make up all thats required

  1. CppProperties = contains all the stuff you want intellisense to know about
  2. task.json = json script that contains build command pretty much sums it up

MS blogs helped me all the way to make life easy to setup

[MInGw Mysys setup] https://blogs.msdn.microsoft.com/vcblog/2017/07/19/using-mingw-and-cygwin-with-visual-cpp-and-open-folder/#comment-433295

[Open folder setup links in order of usefulness ] ` https://blogs.msdn.microsoft.com/vcblog/tag/cppproperties-json/

https://blogs.msdn.microsoft.com/vcblog/category/openfolder/

https://blogs.msdn.microsoft.com/vcblog/2016/11/16/open-any-folder-with-c-sources-in-visual-studio-2017-rc/

https://blogs.msdn.microsoft.com/vcblog/2016/10/05/bring-your-c-codebase-to-visual-studio-with-open-folder/

https://channel9.msdn.com/Events/Connect/2016/120

https://blogs.msdn.microsoft.com/vcblog/2016/10/05/bring-your-c-codebase-to-visual-studio-with-open-folder/ `

I Also have my WinRT Blocks sample OpenFolder GCC project which is currently failing build on WinRT that i could share with you if you provide link to relevant place to dump the projecj folder.

I have added my cpproperties.json and task.json for blocks sample to give you an idea.

CppProperties.txt tasks.vs.txt

had to rename them from .json to .txt just so i can paste here..

Thanks for all your effort, really looking forward to fully replace WindowsCE with WinRT for our products , and the sooner the better for financial reasons. Used to be OPenFolder was only in MSVS preview, now its also in latest version of MSVS.

Thanks