简体   繁体   English

如何使用vs2015为ARM构建一些dll代码

[英]How can I build some dll code to ARM with vs2015

I'am making some uwp app on ARM device(IotCore), and I want use some legacy native dll in uwp app by p/inbvoke. 我正在ARM设备(IotCore)上制作一些uwp应用程序,我想通过p / inbvoke在uwp应用程序中使用一些旧式本机dll。

How can I build this dll project as ARM arch with visual studio 2015? 如何使用Visual Studio 2015将这个dll项目构建为ARM arch?

This is my code, and it works well on my x64 dev machine(win10x64). 这是我的代码,它在我的x64开发机(win10x64)上运行良好。

This is native dll code : 这是本机dll代码:

#ifdef MYSIMPLENATIVEDLL_EXPORTS
#define MYSIMPLENATIVEDLL_API extern "C" __declspec(dllexport)
#else
#define MYSIMPLENATIVEDLL_API extern "C" __declspec(dllimport)
#endif

MYSIMPLENATIVEDLL_API int Add(int x, int y);

MYSIMPLENATIVEDLL_API int Add(int x, int y)
{
    return x + y;
}

This is uwp app code : 这是uwp应用程序代码:

public sealed partial class MainPage : Page
{
    public MainPage()
    {
        this.InitializeComponent();
    }

    protected override async void OnNavigatedTo(NavigationEventArgs e)
    {
        base.OnNavigatedTo(e);

        var result = Add(1, 2);
        var dlg = new MessageDialog($"result : {result}");
        await dlg.ShowAsync();
    }

    [DllImport("MySimpleNativeDll")]
    static extern int Add(int x, int y);
}

full source code : https://github.com/HyundongHwang/MyNativeDllUwpIntegApp 完整的源代码: https : //github.com/HyundongHwang/MyNativeDllUwpIntegApp

When creating the project for the DLL, you need to target "Windows Universal" instead of "Win32". 在为DLL创建项目时,您需要定位“ Windows Universal”而不是“ Win32”。 Such DLL project will have an ARM platform in the platform drop down (like you now have Win32 and x64 there). 这样的DLL项目将在下拉菜单中具有ARM平台(就像您现在在其中具有Win32和x64)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM