Friday, August 3, 2012

Invoking native C/C++ lib from C# and mono

So as a continuation of the last post http://orphanware.blogspot.com/2012/08/making-c-available-through-native-calls.html......here is how u connect using c# and mono (haven't tried .net windows but I'm guessing it's the same)

this one is super ez. here is the full example
using System;
using System.Runtime.InteropServices;

public class HelloWorld
{

        static public void Main( string[] args )
        {
                
MYLIB_helloWorld();

        }

        [DllImport("libmylib.so")]
        private static extern void MYLIB_helloWorld();




}

then run with
gmcs HelloWorld.cs
mono HelloWorld.exe

No comments:

Post a Comment