I compiled a static library in xcode, it contained just one .c source file:
int Get10()
{
return 10;
}
And this is how it’s included in the .cs source file:
[DllImport ("__Internal",EntryPoint="UIRectFrameUsingBlendMode")]
private static extern int Get10 ();
But the return value of Get10() is ‘0’. Notice the EntryPoint is UIRectFrameUsingBlendMode, there is no reason for this, if I remove entrypoint the function Get10() is not found and an exception is thrown to that effect, though that probably has something to do with the problem. The issue is though I’m not sure what entrypoint to define as the lib is basically a single c source file with a function. I had tried using EntryPoint=”Get10″ but that resulted in:
System.EntryPointNotFoundException: Get10 at (wrapper
managed-to-native) ChicksnVixens.ChicksnVixensGame:Get10 () at
ChicksnVixens.ChicksnVixensGame..ctor () [0x000a0] in
/ChicksnVixens/ChicksnVixensGame.cs:36
The code is being compiled and run in MonoDevelop in the iPhone simulator.
Any ideas why?
The EntryPoint should, if present, match the name of your native method. This is useful if you want to rename the method on the managed side (otherwise simply do not use it).
My guess is that your library is not linked correctly or that the Get10 symbol is not visible (e.g. static in C). In such case the runtime should throw an EntryPointNotFoundException.
Both ‘nm’ and ‘otool’ can list what’s exported from your static library (i.e. you should see Get10, otherwise it’s a build issue on your native library). See ‘man’ on both tools to get the lists.