Bug 22593 - ObjectiveC native Linking error with Xamarin iOS
Summary: ObjectiveC native Linking error with Xamarin iOS
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 7.0.0.x
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-09-03 07:17 UTC by Sudipta Biswas
Modified: 2014-09-12 01:04 UTC (History)
5 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Include Binding Project, lib.a and Header file(Objective C) (732.77 KB, application/zip)
2014-09-03 07:17 UTC, Sudipta Biswas
Details
Fixed Binding Project (217.33 KB, application/zip)
2014-09-05 15:56 UTC, Alex Soto [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Sudipta Biswas 2014-09-03 07:17:22 UTC
Created attachment 7894 [details]
Include Binding Project, lib.a and Header file(Objective C)

MTSCRA.a is the UniMag Card Swiper Library for Objective-C. I want to use it in my Xamarin iOS project . So I have made the wrapper class for it's header file and also include necessary framework to it . 

Here is the assemble linking code which is used in "iOS binding project".

[assembly: LinkWith ("libMTSCRAarmv7.a", LinkTarget.ArmV7, ForceLoad = true, Frameworks="AudioToolbox,AudioUnit,ExternalAccessory,Foundation",LinkerFlags="-ObjC -all_load -fno-bjc-arc -lc++")]



But After Generating dll, while I am Compiling it with iPad device it Causes following error . But it properly compiling with simulator . My Xamarin version is 5.0 (build 878)



Error MT5309: Native linking error: file not found: {Project_Directory}/obj/iPhone/Debug/mtouch-cache/libMTSCRAarmv7.a 

Error MT5202: Native linking failed. Please review the build log. (MT5202) (Project_name)



Do you have any solution how i got properly compile this library with my Xamarin iOS project ? I am attaching the binding project with .a file and header and also the Xamarin binding Project . Could you please check it .
Comment 1 Sebastien Pouliot 2014-09-03 08:33:50 UTC
The error is normal. Both the name of your library and the target are ARMv7:

> libMTSCRAarmv7.a", LinkTarget.ArmV7

and the simulator uses i386 (32 bits) or x86_64 (64 bits).

You'll need to create a FAT (multi architecture) static library that will have a slice for i386. Next you hill update the [LinkWith] with this information.

There are documentation about those steps. If you have further questions please contact support (see top, yellow, band).
Comment 2 Sudipta Biswas 2014-09-03 09:05:33 UTC
Actually i don't have the main implementation file for that .a file . Only I have is that .a file . So how could I create a FAT static library . That .a file supports only armv7 architecture . I only want to build and compiling into iPad device not in simulator. please suggest
Comment 3 Sebastien Pouliot 2014-09-03 09:15:11 UTC
You can't convert across CPU architecture. That's the difference between managed (IL is CPU agnostic) and native assembly code (CPU specific).

You'll need to request a i386-compatble (ot a FAT) .a from the component author. Since it deal with hardware (that you probably can't connect to your Mac) it'spossible they do not provide a simulator version.

Note: this is not a bug, please contact support for further assistance
Comment 4 Sudipta Biswas 2014-09-03 09:26:18 UTC
Actually that .a file is for iPhone/ iPad iOS version . The native objective c code with that .a file is properly running into iPad with iOS . But Whenever I want to use it into Xamarin iOS as a native library with Wrapper class of it's header file, it's causing linking error . 
Is ther any solution . Or we still need i386 Compatible .a file .
Comment 5 Sudipta Biswas 2014-09-04 02:10:28 UTC
Actually that .a file is for iPhone/ iPad iOS version . The native objective c
code with that .a file is properly running into iPad with iOS . But Whenever I
want to use it into Xamarin iOS as a native library with Wrapper class of it's
header file, it's causing linking error . 
Is ther any solution . Or we still need i386 Compatible .a file . Can anyone please help me on the same ?
Comment 6 Sudipta Biswas 2014-09-04 07:23:08 UTC
Actually that .a file is for iPhone/ iPad iOS version . The native objective c
code with that .a file is properly running into iPad with iOS . But Whenever I
want to use it into Xamarin iOS as a native library with Wrapper class of it's
header file, it's causing linking error . 
Is ther any solution . Or we still need i386 Compatible .a file . Can anyone
please help me on the same ?
Comment 7 Alex Soto [MSFT] 2014-09-05 15:56:52 UTC
Created attachment 7949 [details]
Fixed Binding Project

Hello Sudipta

This is not a bug in the Xamarin.iOS tooling, please next time go throughout our support channel, you are likely to get a faster response there :). In order to do so please send an email to the personalised address found under your Xamarin Account at https://store.xamarin.com/account/my/subscription.

That said there are several issues found in your binding project.

1. In the attachment you sent us  there is a library called libMTSCRA.a which is a fat library that contains device only archs i.e. armv7 armv7s arm64. This is the one you need to use in your binding project.

2. In the linkwith.cs file you added a comma separated list of frameworks this is wrong, you need a space separated list of frameworks

3. There is no AudioUnit framework per se, you need to reference CoreAudio framework instead and also AVFoundation Framework reference was missing.

4. ApiDefinition files cannot contain enums, enums must be inside StructsAndEnums.cs so we can generate the right Api calls.

Please read our guides on doing iOS bindings found at http://developer.xamarin.com/guides/ios/advanced_topics/binding_objective-c/ where you can find more info about it.

I added the fixed binding project. Hope this helps and again please use our support channel you are likely to get a faster response there.

Alex
Comment 8 Sudipta Biswas 2014-09-08 02:37:43 UTC
Hi,
Thanks guys to give me the fixed project and also the instruction . It is really helpful But  I have included the Binding project into my project and It is giving compiling error . Please see the below error .

"/Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/4.5/Microsoft.Common.targets: Error: Error executing task ResolveAssemblyReference: The file does not contain a manifest
Parameter name: assemblyFile (MagTek)"

I am using  Xamarin 5.0 (build 878). 

Can you guys please help me on this because after properly integrated the Magtek into Xamarin I can upload my project into AppStore .That's why I am again and again disturbing you .
Comment 9 Alex Soto [MSFT] 2014-09-08 19:44:19 UTC
I need more info on what X.I you are using, the easiest way to get exact version information is to use the "Xamarin Studio" menu, "About Xamarin Studio" item, "Show Details" button and copy/paste the
version information (you can use the "Copy Information" button).
Comment 10 Sudipta Biswas 2014-09-09 01:39:58 UTC
Hi ,
Here is the Xamarin Studio Version I am using . Please Check. 

Xamarin Studio
Version 5.0 (build 878)
Installation UUID: 7f28c3da-ad11-4271-b585-aebeb79cd54c
Runtime:
	Mono 3.4.0 ((no/c3fc3ba)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 304000204

Apple Developer Tools
Xcode 5.0 (3332.25)
Build 5A1413

Xamarin.Mac
Xamarin.Mac: Not Installed

Xamarin.Android
Version: 4.12.4 (Starter Edition)
Android SDK: /Users/krishnendu/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		1.6   (API level 4)
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		3.2   (API level 13)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

Xamarin.iOS
Version: 7.2.3.39 (Business Edition)
Hash: fc6f56b
Branch: 
Build date: 2014-05-19 19:10:29-0400

Build Information
Release ID: 500000878
Git revision: bcd66920d963483e7d638a2339c4022fe035b529
Build date: 2014-05-27 17:36:26-04
Xamarin addins: da9064ce55b0fa90930a7c437a4cc1ae0e5c778c

Operating System
Mac OS X 10.8.4
Darwin Krishnendus-Mac-mini.local 12.4.0 Darwin Kernel Version 12.4.0
    Wed May  1 17:57:12 PDT 2013
    root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64
Comment 11 Sudipta Biswas 2014-09-10 02:24:31 UTC
Can you please help me out . I am really stuck here ....
Comment 12 Alex Soto [MSFT] 2014-09-11 22:11:10 UTC
Please update to latest stable version of Xamarin.iOS and try again.
Comment 13 Sudipta Biswas 2014-09-12 01:04:44 UTC
Hi man ,
Thanks a lot . Thanks for helping me out . It's working now . I have successfully integrated it into Xamarin and also update my Xamarin to latest one . 
Thanks again .