The following forum(s) are migrating to a new home on Microsoft Q&A (Preview): Developing Universal Windows apps!

Ask new questions on Microsoft Q&A (Preview).
Interact with existing posts until December 13, 2019, after which content will be closed to all new and existing posts.

Learn More

 none
[UWP]Implementing C++ console application in c# uwp RRS feed

  • Question

  •  i have created an app in uwp c# and wanted to implement image comparison method  which has been created in c++ using opencv Technology(http://www.codeproject.com/Articles/24809/Image-Alignment-Algorithms).i come across following hurdles

    1.This image alignment algorithms works only for x64 platform.It should work on ARM and x86 mode also.

    2.I got  one reference for using opencv on uwp (http://osconqsc2015.azurewebsites.net/qsccontent/opencv/opencv.html) but it is not clear .

    my image alignment algorithm is working properly which is created in c++, and my app on uwp c# is also working properly .i want to use that c++ console image alignment

    feature in my c# uwp .how to achieve that.


    • Edited by Barry Wang Thursday, November 3, 2016 2:46 AM title tag
    Tuesday, October 25, 2016 12:57 PM

All replies

  • Hi pariwesh,

    [Updated 3/30/2016]Welcome to the Developing Universal Windows apps forum!
    Please read the sticky posts, especially the Guide to posting: subject line tags and Known Issues for Windows 10 SDK and Tools

    As far as I know, you could achieve that by wrapping the C++ code with a Windows Runtime Component in your UWP solution and calling it from C# project. 
    For how to create a Windows Runtime Component in C++, you could refer to the following link.
    https://msdn.microsoft.com/en-us/library/hh441569.aspx
    For something about passing “Windows Runtime types” to your C# managed project, you could refer to the following link.
    https://msdn.microsoft.com/en-us/library/br230301.aspx
    For how to use existing C++ Code in a UWP app, you could refer to the following link. 
    https://msdn.microsoft.com/en-us/library/mt186162.aspx
    After creating the Windows Runtime Component, you need to change the precompiled header setting, include the directories and libs as you do in the console application. For Visual Studio 2015, you could refer to the following steps.
    Windows Runtime Component -> Properties -> Configuration Properties -> C/C++ -> Precompiled Headers -> Precompiled Header -> [choose “Not Using Precompiled Headers” if needed]
    Windows Runtime Component -> Properties -> Configuration Properties -> C/C++ -> General -> Additional Include Directories -> [add the three include directories]
    Windows Runtime Component -> Properties -> Configuration Properties -> Linker -> General -> Additional Library Directories -> [add the library directory]
    Windows Runtime Component -> Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies -> [add the three libs]
    Then you need to add the “cv100.dll, cxcore100.dll, highgui100.dll, libguide40.dll”(located at OpenCV\bin) to the UWP C# project by “right-click the project and add existing item”.
    After adding reference of the Windows Runtime Component to the C# project, your solution may compile and it may looks like the following screenshot.

    Best Regards,
    David

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    • Proposed as answer by David_FF Wednesday, October 26, 2016 4:29 PM
    Wednesday, October 26, 2016 12:42 PM
  • Thx david  
    Wednesday, October 26, 2016 2:02 PM