Bug 296 - MonoTouch does not build for device giving error code 134
Summary: MonoTouch does not build for device giving error code 134
Status: RESOLVED NOT_ON_ROADMAP
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools ()
Version: 4.x
Hardware: Macintosh Mac OS
: --- critical
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
URL:
Depends on: 238
Blocks:
  Show dependency tree
 
Reported: 2011-08-15 10:24 UTC by Ahmed Hakeem
Modified: 2011-08-17 11:34 UTC (History)
4 users (show)

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


Attachments
all which may be causing the error on compile. (92.00 KB, application/octet-stream)
2011-08-15 10:24 UTC, Ahmed Hakeem
Details
dlls required for jabber.dll (88.00 KB, application/octet-stream)
2011-08-16 05:32 UTC, Ahmed Hakeem
Details
dlls required for jabber.dll (76.50 KB, application/octet-stream)
2011-08-16 05:33 UTC, Ahmed Hakeem
Details
dlls required for jabber.dll (334.50 KB, application/octet-stream)
2011-08-16 05:33 UTC, Ahmed Hakeem
Details
static lib of box2d physics library, with extra extern "c' functions added for p/invoking and some minor new functionality added to various classes (1.63 MB, application/octet-stream)
2011-08-16 05:52 UTC, Ahmed Hakeem
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 NOT_ON_ROADMAP

Description Ahmed Hakeem 2011-08-15 10:24:58 UTC
Created attachment 127 [details]
all which may be causing the error on compile.

From this stack overflow question: http://stackoverflow.com/questions/7065327/attempting-to-build-for-ios-device-results-in-build-failure/7065934#7065934

I've also attached Jabber.dll as per poupou's request..
Comment 1 Sebastien Pouliot 2011-08-15 11:32:16 UTC
The assembly is trying to refer a method that does not exists, likely something from System.Reflection.Emit.

imac:tmp sebastienpouliot$ MONO_PATH=. /Developer/MonoTouch/usr/bin/arm-darwin-mono --debug --aot=full,static,asmonly,soft-debug,iphone-abi,outfile=Jabber.dll.6.s Jabber.dllMono Ahead of Time compiler - compiling assembly /Developer/MonoTouch/Source/monotouch/tmp/Jabber.dll
Failed to load method 0x6000042 from '/Developer/MonoTouch/Source/monotouch/tmp/Jabber.dll'.
Comment 2 Sebastien Pouliot 2011-08-15 11:38:39 UTC
Mono: Could not load file or assembly 'ExEnEmTouch, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

I did not think Jabber.dll depended on something else. Please provide all non-SDK assemblies that are referenced by Jabber.dll (you can mark the comment/attachment as private).
Comment 3 Jeffrey Stedfast 2011-08-15 12:49:15 UTC
Is this a duplicate of bug #164?
Comment 4 Sebastien Pouliot 2011-08-15 12:51:26 UTC
Jeff, no #164 is LLVM related (read the stackoverflow link) this one is not
Comment 5 Ahmed Hakeem 2011-08-16 05:32:58 UTC
Created attachment 136 [details]
dlls required for jabber.dll
Comment 6 Ahmed Hakeem 2011-08-16 05:33:17 UTC
Created attachment 137 [details]
dlls required for jabber.dll
Comment 7 Ahmed Hakeem 2011-08-16 05:33:51 UTC
Created attachment 138 [details]
dlls required for jabber.dll
Comment 8 Ahmed Hakeem 2011-08-16 05:35:12 UTC
(In reply to comment #2)
> Mono: Could not load file or assembly 'ExEnEmTouch, Version=1.0.0.0,
> Culture=neutral, PublicKeyToken=null' or one of its dependencies.
> 
> I did not think Jabber.dll depended on something else. Please provide all
> non-SDK assemblies that are referenced by Jabber.dll (you can mark the
> comment/attachment as private).

I just added all the relevant DLLs, I think ExEnEmTouch relies on ExEnCore. If there's still issues I'd be happy to upload the original source/monodevelop project to my website and send you a link with password to extract from zip (would probably have to be a private email in that case).
Comment 9 Ahmed Hakeem 2011-08-16 05:52:11 UTC
Created attachment 139 [details]
static lib of box2d physics library, with extra extern "c' functions added for p/invoking and some minor new functionality added to various classes

this is a C++ static lib compiled in x-code (-cxx -gcc_flags "-L${ProjectDir}/box2D/iPhoneSim -lBox2D -force_load ${ProjectDir}/box2D/iPhoneSim/libBox2D.a"
) which is used as part of the compile of the app and required by the physics engine (which exists in Jabber.dll).

Whether or not this library is included doesn't seem to matter as I get compile errors. I've attached it just in case it's needed.
Comment 10 Sebastien Pouliot 2011-08-16 09:01:45 UTC
That should help a lot. I'll let you know if anything else is needed. Thanks!
Comment 11 Ahmed Hakeem 2011-08-16 09:57:09 UTC
Would just like to update, I think I've narrowed down the cause of the problem. I have a class called Farworld_IOS, it's essentially a C# wrapper class for the C++ Box2D physics engine.

The class when instantiated does nothing but I found one of the functions within the class (Initialize(Vector2 vector)) was the source of the problem because inside it I set up some delegate callbacks.

These delegate callbacks are sent to Box2D as function pointers where Box2D invokes them during specific times.

The delegates are:

delegate bool OnContact(MyCollisionEvent ev);
delegate bool ContactOver(MyCollisionEvent ev);

The functions I make them callback to are:

[MonoTouch.MonoPInvokeCallback(typeof(OnContact))]
bool ContactStart(MyCollisionEvent ev)
{
 (...)
}

and

[MonoTouch.MonoPInvokeCallback(typeof(ContactOver))]
		bool ContactEnd(MyCollisionEvent ev)
{
  (...)
}

And I obviously set them up like follows:

public void Initialize(Vector2 gravity)
{
   StartContact += ContactStart;
   FinishContact += ContactEnd;

(...)
}

Now if I remove those two lines in the Initialize function the error stops happening. Also if I comment out the MonoTouch.MonoPInvokeCallback's from the functions I also don't get that build error anymore.

So I believe the MonoPInvokeCallback is the cause of the compile error. As I said before they only cause the issue when being built for a device. They build for the simulator (and indeed run in the simulator) without a hitch...
Comment 12 Sebastien Pouliot 2011-08-16 10:21:07 UTC
As stated in http://ios.xamarin.com/Documentation/Limitations#Reverse_Callbacks

"The methods have to be static methods, there is no support for instance methods"

This is an AOT requirement so it does not affect the simulator (which uses the JIT to be faster to build/debug).

In your case "Jabber.Physics.FarWorld_IOS::TestFunc" must be static. There could be other method, but that's the one that cause the AOT compiler to abort.

I'll do some changes so this gets a bit more "visual" than (one of the many) error 134 and include the method name - but the "real" fix to the issue must be in your own code.
Comment 13 Sebastien Pouliot 2011-08-16 15:19:13 UTC
Closing the issue. Sadly this limitation needs to be fixed in the user code.
Comment 14 Sebastien Pouliot 2011-08-17 11:34:45 UTC
Just to let you know that future version of MonoTouch will show something like:

AOT restriction: Method 'Namespace.Type:method ()' must be static since it is decorated with [MonoPInvokeCallback]. See http://ios.xamarin.com/Documentation/Limitations#Reverse_Callbacks

when an invalid (for AOT) callback is being compiled. This will make it easier to spot such issues.