Bug 39681 - MT3001 error when using iOS bindings library
Summary: MT3001 error when using iOS bindings library
Alias: None
Product: iOS
Classification: Xamarin
Component: Mono runtime / AOT compiler ()
Version: XI 9.4 (iOS 9.2)
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: (C7)
Assignee: Zoltan Varga
Depends on:
Reported: 2016-03-16 12:57 UTC by Andrey Filyakov
Modified: 2016-03-16 14:30 UTC (History)
3 users (show)

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

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:

Description Andrey Filyakov 2016-03-16 12:57:06 UTC
I have made Bindings iOS library (StarIOSDK in attached solution). The particular library builds successfully. But when I'm trying to build iOS project (StarIOTest in attached solution) for iPhone, I get MT3001 error with description: 

"/Users/andreyfilyakov/Dev/StarIOSDKTest/StarIOSDKTest/MTOUCH: Error MT3001: Could not AOT the assembly '/Users/andreyfilyakov/Dev/StarIOSDKTest/StarIOSDKTest/obj/iPhone/Debug/build-iphone5.4-9.2.1/mtouch-cache/Build/StarIOSDK.dll' (MT3001) (StarIOSDKTest)"

When I'm trying to build iOS project for iPhoneSimulator, the project builds successfully.

For more details see solution in attachment.

Thank you,
Andrey Filyakov.
Comment 1 Andrey Filyakov 2016-03-16 13:05:33 UTC
URL for downloading test project (the project is too big for attachments):
Comment 2 Sebastien Pouliot 2016-03-16 14:12:04 UTC
@Zoltan, this happens with C7 too.

Build details:

		AOT Compilation exited with code 134, command:
		MONO_PATH=/Users/poupou/Downloads/StarIOSDKTest/StarIOSDKTest/obj/iPhone/Debug/build-iphone8.2-9.2.1/mtouch-cache/Build /Users/poupou/git/c7/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/bin/arm64-darwin-mono-sgen --debug -O=gsharedvt -O=float32  --aot=mtriple=arm64-ios,data-outfile=/Users/poupou/Downloads/StarIOSDKTest/StarIOSDKTest/obj/iPhone/Debug/build-iphone8.2-9.2.1/mtouch-cache/StarIOSDK.arm64.aotdata,static,asmonly,direct-icalls,full,soft-debug,dwarfdebug,no-direct-calls,outfile=/Users/poupou/Downloads/StarIOSDKTest/StarIOSDKTest/obj/iPhone/Debug/build-iphone8.2-9.2.1/mtouch-cache/StarIOSDK.dll.arm64.s "/Users/poupou/Downloads/StarIOSDKTest/StarIOSDKTest/obj/iPhone/Debug/build-iphone8.2-9.2.1/mtouch-cache/Build/StarIOSDK.dll"
		Mono Ahead of Time compiler - compiling assembly /Users/poupou/Downloads/StarIOSDKTest/StarIOSDKTest/obj/iPhone/Debug/build-iphone8.2-9.2.1/mtouch-cache/Build/StarIOSDK.dll
		Structure field of type Byte[] can't be marshalled as LPArray
Comment 3 Sebastien Pouliot 2016-03-16 14:27:02 UTC
@Andrey we should not report this as a general MT3001 error but your bindings are incorrect. Each of your structures have something like:

> public uint rawLength;
> public byte[] raw;

There's not enough data to marshal this, e.g. 

> [MarshalAs(UnmanagedType.LPArray, SizeConst = XXX)]

but as the size is not known (at build time) you better define your structures with an `IntPtr`, e.g.

> public uint rawLength;
> public IntPtr raw;

That will make the MT3001 error go away (but you have other issues as some native ObjC symbols are reported as missing).
Comment 4 Andrey Filyakov 2016-03-16 14:30:32 UTC
@Sebastien Thanks a lot! I'll try to resolve other issues.