Problems linking native library with Xamarin.iOS 7.2.1.42

DanBelcherDanBelcher USMember ✭✭

I updated to Xamarin.iOS 7.2.1.42 today and I am now getting lots of MT5210 (Native linking failed, undefined symbol) errors with my native C++ library. I have read the notes here and have tried to use the legacy registrar settings, but without any luck...

Here are my additional mtouch arguments (for Simulator) that worked before updating to 7.2.1.42:

-cxx -gcc_flags "-L${SolutionDir}/${ProjectDir}/libs/ -lmylibrary -force_load ${SolutionDir}/${ProjectDir}/libs/libmylibrary.a" --registrar:dynamic

And I've tried changing them to:

-cxx -gcc_flags "-L${SolutionDir}/${ProjectDir}/libs/ -lmylibrary -force_load ${SolutionDir}/${ProjectDir}/libs/libmylibrary.a" --registrar:olddynamic

and

-cxx -gcc_flags "-L${SolutionDir}/${ProjectDir}/libs/ -lmylibrary -force_load ${SolutionDir}/${ProjectDir}/libs/libmylibrary.a" --registrar:legacy

without any luck.

Additionally, I've tried wrapping this library in a binding project and I get the same errors.

Any ideas?

Posts

  • SebastienPouliotSebastienPouliot CAXamarin Team Xamurai

    Can you post (e.g. a link to a gist) your full build log ? It might not be related to the registrar but, without more details, it's hard to guess what could be wrong.

  • DanBelcherDanBelcher USMember ✭✭

    @SebastienPouliot‌ Understood. Here is the build log before changing the registrar settings...as changing them gives the same errors:
    http://pastebin.com/tUTcRaL6

  • SebastienPouliotSebastienPouliot CAXamarin Team Xamurai

    The openNURBS library looks to be C++ so I do not think it's related to the registrar.

    Now it's uncommon to use Release on the iOS Simulator. Are you sure you could not have switched from Debug to Release configuration ?

    It's often easy to forget to update the Release configuration when modifying the Debug options (e.g. when adding additional mtouch arguments).

    What happens on Debug or when you build for devices ?

  • DanBelcherDanBelcher USMember ✭✭

    @SebastienPouliot‌ That build log is from a Debug configuration. Building for Debug on devices yields the same results.

    Here are my additional mtouch arguments for Release | Device:

    -cxx -gcc_flags "-L${SolutionDir}/RV.Touch/libs/ -lopennurbs -force_load ${SolutionDir}/RV.Touch/libs/libopennurbs.a"

    This has been working without issue until the update to 7.2.1.42 today.

  • SebastienPouliotSebastienPouliot CAXamarin Team Xamurai

    Oops my bad. There was a lot of Release in the paths of the logs (but unrelated) but the build itself is from the Debug configuration.

    Could you try to build a small test case (e.g. that use the library, but without the rest of your application) and attach that to a bug report ?

    Also were you using 7.2.0 or something older because updating ? or did you update other things (e.g. Xcode) ?

  • DanBelcherDanBelcher USMember ✭✭

    @SebastienPouliot‌ No worries. Yeah, there's a lot of Release going on there.

    Yes, I can put together a bug report with a test case.

    As far as I remember, before updating, I was using whatever previous version of Xamarin.iOS was in the stable channel. Yes, I updated Xcode to 5.1.1, but that was days ago.

  • DanBelcherDanBelcher USMember ✭✭

    @SebastienPouliot‌

    Bug submitted

    Sincerely hoping this is an easy fix (or something small that I'm doing wrong) as the entire projects depends on this library.

    Thanks again for looking into it.

  • JamesHeaneyJamesHeaney GBMember

    I can no longer debug on a device either!

    error MT5211: Native linking failed, 
    error MT5210: Native linking failed,
    error MT5202: Native linking failed,
    

    It was fine before the last Xamarin update.

  • DanielNordmarkDanielNordmark SEMember ✭✭

    Me too, same problems.

  • DanBelcherDanBelcher USMember ✭✭

    Anyone know an quick way to rollback from 7.2.1 to 7.2.0?

  • DeanCleaverDeanCleaver USMember ✭✭✭

    @DanBelcher‌ if you go to Xamarin.com, log into your account, select Downloads and you can pick prior releases to download and install.

  • VelocityVelocity NZMember ✭✭✭

    Having problems with 7.2.1 also, native linking fails for ShinobiEssentials and ShinobiGrid components available on the Xamarin component store.

    Reverting to 7.2 - not cool when a minor dot release like this breaks a considerable amount of functionality, especially 3rd party components available on the component store.

  • EhsanSemsarEhsanSemsar USMember, University

    I'm also getting an error after updating to 7.2.1. I can't run my project on iOS simulator and the app crashes. Here is the error:

    Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Unable to instantiate the UIApplication delegate instance. No class named [Project Name].Touch.AppDelegate is loaded.

    Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Unable to instantiate the UIApplication delegate instance. No class named [Project Name].Touch.AppDelegate is loaded.
    at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
    at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
    at Sanofi.Hector.Touch.Application.Main (System.String[] args) [0x0000e] in [Project Name].Touch/Main.cs:19

  • RolfBjarneKvingeRolfBjarneKvinge USXamarin Team Xamurai

    @EhsanSemsar: are any other exception messages shown in the Application Output at startup?

  • EhsanSemsarEhsanSemsar USMember, University

    I think I found the problem. The latest version of Xamarin.ios SDK for Mac Os is not compatable with the latest version of Xamarin.ios SDK for Windows. I use visual studio and when I downgrade the SDK it for Mac OS it works fine.

  • BrendanZagaeskiBrendanZagaeski USForum Administrator, Xamarin Team Xamurai
    edited May 2014

    For folks seeing these errors with the upgrade to 7.2.1, be sure to read through the documentation about the new registrar to see if it might apply:

    Two particularly common forms of errors with the new registrar are:

    1. Error MT5210: Native linking failed, undefined symbol: _foo. Please verify
      that all the necessary frameworks have been referenced and native libraries are
      properly linked in. (MT5210)

    2. Error MT5211: Native linking failed, undefined Objective-C class:
      _OBJC_CLASS_$_MyDelegate. If '_OBJC_CLASS_$_MyDelegate' is a protocol from a
      third-party binding, please check that it has the [Protocol] attribute in its
      api definition file, otherwise verify that all the necessary frameworks have
      been referenced and native libraries are properly linked in. (MT5211)

    Workarounds, fixes

    1. As mentioned on the bug report from earlier, there are a few ways to work around this problem:

      • Remove the P/Invokes in question from your source code. This is "correct" fix.
      • Enable the managed linker for all assemblies (this is done in the project's
        iOS Build options, by setting "Linker Behavior" to "All assemblies"). This will
        effectively remove all the P/Invokes you don't use from the app (automatically,
        instead of manually like the previous point). The downside is that this will
        make your simulator builds somewhat slower, and it may break your app if it's
        using reflection - more information about the linker can be found here:
        http://docs.xamarin.com/guides/ios/advanced_topics/linker/)

      • Create a second native library which contains the missing native symbols.
        Note that this is merely a workaround (if you happen to try to call those
        functions, your app will crash). For example, you can define variables for the missing names:

        void *foo = 0;  
        

        ... and then compile the file into a new native library:

        clang -arch i386 -arch x86_64 -arch armv7 -arch armv7s -arch arm64 -c mydefs.c -o mydefs.o
        
    2. As mentioned in the release notes, you can work around this problem temporarily by adding --registrar:legacy to "Project Options -> iOS Build -> Additional mtouch arguments".

      To fix the problem, you'll need to add the [Protocol] attribute (as requested by the error message), and then recompile the binding library. If you don't have access to the source for the binding library, the author of the library will have to perform this step.

  • SreeeeSreeee INMember ✭✭✭✭✭

    @EhsanSemsar said:
    I think I found the problem. The latest version of Xamarin.ios SDK for Mac Os is not compatible with the latest version of Xamarin.ios SDK for Windows. I use visual studio and when I downgrade the SDK it for Mac OS it works fine.

    I am also getting the same exception:
    Foundation.MonoTouchException has been thrown
    Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Unable to instantiate the UIApplication delegate instance. No class named AppDelegate is loaded.

    Screenshot:

    I didn't understand the solution you prefer, I am using visual studio(in mac) for the development, can you help me to solve this issue?
    Thanks in advance :)

  • SreeeeSreeee INMember ✭✭✭✭✭

    @EhsanSemsar said:
    I think I found the problem. The latest version of Xamarin.ios SDK for Mac Os is not compatable with the latest version of Xamarin.ios SDK for Windows. I use visual studio and when I downgrade the SDK it for Mac OS it works fine.

    I am using visual studio 2017 community in mac and using xcode 9.2(latest version)

  • SreeeeSreeee INMember ✭✭✭✭✭

    @EhsanSemsar said:
    I'm also getting an error after updating to 7.2.1. I can't run my project on iOS simulator and the app crashes. Here is the error:

    Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Unable to instantiate the UIApplication delegate instance. No class named [Project Name].Touch.AppDelegate is loaded.

    Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Unable to instantiate the UIApplication delegate instance. No class named [Project Name].Touch.AppDelegate is loaded.
    at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
    at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
    at Sanofi.Hector.Touch.Application.Main (System.String[] args) [0x0000e] in [Project Name].Touch/Main.cs:19

    Solve this issue by setting the Build Action property of AppDelegate.cs to Combile :)
    It is a trap for young players :)

  • TussharTusshar INMember ✭✭

    hi All,
    i have made a binding library, But it's not working in my application and giving me error like as:
    MTOUCH : error MT5211: Native linking failed, undefined Objective-C class
    and i have tried to add Protocol attribute on it , after that my code is build successfully but getting an exception when calling the methods and exception ios 'Foundation.ModelNotImplementedException'. i am facing this from long time but not getting any solution So, Please help me with this issue.

    Thank You

  • TussharTusshar INMember ✭✭

    @Sreeee Solve this issue by setting the Build Action property of AppDelegate.cs to Combile :)
    It is a trap for young players :)

    How it could be done on AppDelegate.cs file. cause i am new in Xamarin , So, i don't understand "Build Action property of AppDelegate.cs to Combile"

  • SreeeeSreeee INMember ✭✭✭✭✭
    edited March 2018

    Hi @Tusshar

    Right click on the AppDelegate.cs file in the solution explorer and select properties option, and set the Build Action property to Combile

Sign In or Register to comment.