简体   繁体   中英

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.

How can I build this dll project as ARM arch with visual studio 2015?

This is my code, and it works well on my x64 dev machine(win10x64).

This is native dll code :

#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 :

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

When creating the project for the DLL, you need to target "Windows Universal" instead of "Win32". Such DLL project will have an ARM platform in the platform drop down (like you now have Win32 and x64 there).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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