jsnmc
Posts: 7
Joined: Tue May 12, 2015 3:12 pm

C++ native

Tue May 12, 2015 3:18 pm

Can I utilize native C++ code on the Pi 2 with Windows 10? I got my first C# program running and only briefly looked at the C++ projects in VS, but they looked like managed C++/universal. I want to P/Invoke into an existing C++ project if that would be possible - It already supports ARM.

thanks,
jsnmc

mimi123
Posts: 583
Joined: Thu Aug 22, 2013 3:32 pm

Re: C++ native

Tue May 12, 2015 6:05 pm

jsnmc wrote:Can I utilize native C++ code on the Pi 2 with Windows 10? I got my first C# program running and only briefly looked at the C++ projects in VS, but they looked like managed C++/universal. I want to P/Invoke into an existing C++ project if that would be possible - It already supports ARM.

thanks,
jsnmc
The Win32 console API is supported so you can run Windows RT console apps(see the instructions of how to enable Desktop Win32 dev on VS2012/3.

jsnmc
Posts: 7
Joined: Tue May 12, 2015 3:12 pm

Re: C++ native

Tue May 12, 2015 6:09 pm

Great! thanks.

jtanner_msft
Posts: 105
Joined: Fri May 01, 2015 7:12 pm

Re: C++ native

Tue May 12, 2015 6:59 pm

Here is a sample to a C++ console app that you can build and run on your Windows 10 IoT Core Rpi2 device:
http://ms-iot.github.io/content/win10/s ... oleApp.htm

I do want to point out that while C++ Console apps are supported, that doesn’t mean that every previous Win32 C++ console app can just be compiled and run. (or copied from Windows RT and run)

What we do offer is a Windows 10 IoT Core API porting tool that you can use to analyze your existing projects with:
http://ms-iot.github.io/content/win10/t ... ngTool.htm

By using it it’ll let you know if you are calling any APIs that are unsupported, and if alternatives exist on Windows 10 IoT Core.

I hope that helps.
Jonathan Tanner | Microsoft | Windows 10 IoT Core Insider Preview Support | This posting is provided 'as is' with no warranties and confers no rights.

mimi123
Posts: 583
Joined: Thu Aug 22, 2013 3:32 pm

Re: C++ native

Tue May 12, 2015 7:20 pm

jtanner_msft wrote:Here is a sample to a C++ console app that you can build and run on your Windows 10 IoT Core Rpi2 device:
http://ms-iot.github.io/content/win10/s ... oleApp.htm

I do want to point out that while C++ Console apps are supported, that doesn’t mean that every previous Win32 C++ console app can just be compiled and run. (or copied from Windows RT and run)

What we do offer is a Windows 10 IoT Core API porting tool that you can use to analyze your existing projects with:
http://ms-iot.github.io/content/win10/t ... ngTool.htm

By using it it’ll let you know if you are calling any APIs that are unsupported, and if alternatives exist on Windows 10 IoT Core.

I hope that helps.
It's way too complete. Apache2.4 can run with a simple recompile

jsnmc
Posts: 7
Joined: Tue May 12, 2015 3:12 pm

Re: C++ native

Wed May 13, 2015 2:59 am

jtanner_msft wrote:Here is a sample to a C++ console app that you can build and run on your Windows 10 IoT Core Rpi2
..
..
I hope that helps.
@jtanner_msft that is a good reference. For my project tonight, I was just trying to have my C# project P/Invoke into a C++ dll that targets ARM. I can't seem to get the deploy step to copy the C++ .dll onto the PI. Is this scenario supported and if so how do I include it in the deployment step? I have tried a few things like including the dll as content. If it is not supported, I guess that means that I will have to go all C++ ?

thanks again.

jtanner_msft
Posts: 105
Joined: Fri May 01, 2015 7:12 pm

Re: C++ native

Wed May 13, 2015 6:21 pm

Hi Jsnmc,

I haven’t had a chance to try this scenario yet myself, but I did find a few pointers that you might want to review for this type of scenario:
https://msdn.microsoft.com/en-us/library/hh441569.aspx

http://blogs.msdn.com/b/win8devsupport/ ... oject.aspx

If those don’t help, then you could also post additional UAP specific questions here:
https://social.msdn.microsoft.com/Forum ... nativecode

I hope that helps.
Jonathan Tanner | Microsoft | Windows 10 IoT Core Insider Preview Support | This posting is provided 'as is' with no warranties and confers no rights.

jsnmc
Posts: 7
Joined: Tue May 12, 2015 3:12 pm

Re: C++ native

Thu May 14, 2015 3:04 am

Thanks for the information jtanner_msft - I got it to work by using a WRT component that wraps the C++ static library. From the C# project I can reference the WRT component and make the call into the exposed C++ function. Not as simple as a P/Invoke, but at least it works and is pretty straight forward in the grand scheme of things.

// C#
// Create the object -> Class1 is a C++ Universal WRT component that calls into a standard
// ARM C++ static library
var nativeObject = new WindowsRuntimeComponent1.Class1();
var ret = nativeObject.TestMe();

Return to “Windows 10 for IoT”