Help with DllImport

Hello!

I created simple CocoaTouch library with one method

testLib.h file:
#import "testLib.h"
@implementation testLib
- (int) addA: (int) a toB: (int) b {
return a + b;
}
@end

testLib.mm file:
#import "testLib.h"
@implementation testLib
- (int) addA: (int) a toB: (int) b {
return a + b;
}
@end

And trying to import it into my Xamarin project like this:
public class TestImport
{
[DllImport("__Internal")]
public static extern int addAtoB(int a, int b);
}

I also added following options to IOSbuild parameters:
-cxx -gcc_flags "-L${ProjectDir} -ltestLib -framework Foundation -force_load ${ProjectDir}/libtestLib.a"

But while compiling I get next error:
/Users/ilozgach/Projects/smartthermometer/iOS/MTOUCH: Error MT5214: Native linking failed, undefined symbol: _addAtoB. This symbol was referenced by the managed member smartthermometer.iOS.TestImport.addAtoB. Please verify that all the necessary frameworks have been referenced and native libraries linked. (MT5214) (smartthermometer.iOS)

So the linker is looking for _addAtoB method which actually has no underscore prefix. Could anyone help me where I'm wrong?

Tagged:
Sign In or Register to comment.