[Mono-osx] managed c# call to unmanaged c++
dman at nycap.rr.com
dman at nycap.rr.com
Mon Nov 22 10:55:58 EST 2010
Hello
I am trying to call unmanaged code from managed c# code by using p/invoke.
I have the following dllimport attribute in my managed DLL
[dllimport("UnMan")]
public static extern in CalcExampleSum(int a, int b);
I have a console app which references this managed dll
the code is as follows
static Void Main(String args[])
{
int a= 25;
int b=34;
int total=0;
total= NativeMethods.CalcExampleSum(a,b);
System.Console.Writeline("The Sum is:{0}",total);
System.console.Readline();
}
I created my libUnMan.dylib in xcode the code follows
UnMan.h
extern "C"
{
int CalcExampleSum(int a ,int b);
}
UnMan.cp
extern "C"
{
int CalcExampleSum(int a, int b)
{
int total=0;
total = a + b;
return total;
}
}
This code works on open SUSE. It builds on all platforms and runs on all except Mac OSX so assume any syntax errors are transcription errors.
Where do I have to put the dylib so that it is found?
http://www.mono-project.com/Interop_with_Native_Libraries#Library_Handling
I have done the things listed on the page listed above.
I believe it is a search path problem I have put the libUnMan.dylib everywhere trying to solve the problem still no luck.
I am open to all ideas!
More information about the Mono-osx
mailing list