Forum Visual Studio
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Xamarin iOS Native Linking from Visual Studio

YakoYako USMember ✭✭

I am building a simple sample app, found in https://github.com/bryonbaker/Xamarin-PInvoke-Example

I've tried building this on my mac using Xamarin Studio and it compiles and runs fine. However doing the same on Visual Studio 2015 gives me the following errors.

Severity Code Description Project File Line
Error Native linking failed. Please review the build log. XamarinPInvokeTest C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets 654
Error Native linking failed. Please review the build log and the user flags provided to gcc: -L/Users/jordanfoo/Library/Caches/Xamarin/mtbs/builds/XamarinPInvokeTest/2cbf0a2bc786dbccac7d4baa37e83b81 -lPinvokeTestSDK -force_load /Users/jordanfoo/Library/Caches/Xamarin/mtbs/builds/XamarinPInvokeTest/2cbf0a2bc786dbccac7d4baa37e83b81/libPinvokeTestSDK.a "-Wl,-map,/Users/jordanfoo/Library/Caches/Xamarin/mtbs/builds/XamarinPInvokeTest/2cbf0a2bc786dbccac7d4baa37e83b81/output.map" XamarinPInvokeTest C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets 654
Error Native linking error: file not found: /Users/jordanfoo/Library/Caches/Xamarin/mtbs/builds/XamarinPInvokeTest/2cbf0a2bc786dbccac7d4baa37e83b81/libPinvokeTestSDK.a XamarinPInvokeTest C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets 654]

Full build log attached.
I can confirm that the libs are not being copied over. Because when I tried to copy the libs accross to the mac build, Visual studio immediate compiles and runs fine.
Is this a known issue with the current stable build? I didn't find anything current on the bug.

Previous potentially relevant issue:
https://bugzilla.xamarin.com/show_bug.cgi?id=23164
https://bugzilla.xamarin.com/show_bug.cgi?id=23635
https://forums.xamarin.com/discussion/24206/native-linking-failing-from-vs2013-builds
https://bugzilla.xamarin.com/show_bug.cgi?id=30262

Xamarin 3.11.1537.0 (a11147b)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android 5.1.7.12 (53fce3730830417896a42f365a5ba35f1ee58d9d)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS 9.0.1.0 (73db6324ad6864caae30bf4010c185598d262e69)
Visual Studio extension to enable development for Xamarin.iOS.

Answers

  • AdamLangleyAdamLangley NZMember ✭✭

    I have recently hit this myself after upgrading my XS today and doing a build of an old product from Visual Studio. I can confirm that setting "Copy to Output Directory" for your shared native libs to anything other than "do not copy" will fix the issue.

    WARNING AND NOTE TO XAMARIN: Your shared libs in your project tree must be physical files, they cannot be linked to files at a different location. This one caught me out. Adding the files in Visual Studio using "Link To" will prevent the file from being copied across to the Mac, no matter what you set the output to.

  • YakoYako USMember ✭✭

    I see. Thanks for the heads up.
    I only got around the issue by creating an iOS Binding Library instead. That seemed to work fine.

Sign In or Register to comment.