diff --git a/examples/Hello/Hello.cpp b/examples/Hello/Hello.cpp new file mode 100644 index 00000000..d51ab963 --- /dev/null +++ b/examples/Hello/Hello.cpp @@ -0,0 +1,24 @@ +#include +#include "Hello.h" + +using namespace std; + +void +Hello::PrintHello () +{ + cout << "Hello, World!\n"; +} + +Hello::Hello () +{ +} + +int +main () +{ + Hello h; + + h.PrintHello (); + + return 0; +} diff --git a/examples/Hello/Hello.cs b/examples/Hello/Hello.cs new file mode 100644 index 00000000..0a03ae94 --- /dev/null +++ b/examples/Hello/Hello.cs @@ -0,0 +1,12 @@ +using System; +using Mono.VisualC.Interop; + +public class HelloExample +{ + public static void Main (String[] args) { + var h = new Hello.Hello (); + h.PrintHello (); + } +} + + \ No newline at end of file diff --git a/examples/Hello/Hello.h b/examples/Hello/Hello.h new file mode 100644 index 00000000..f24f341e --- /dev/null +++ b/examples/Hello/Hello.h @@ -0,0 +1,8 @@ + +class Hello +{ +public: + Hello (); + + void PrintHello (); +}; diff --git a/examples/Hello/Makefile b/examples/Hello/Makefile new file mode 100644 index 00000000..d546dbad --- /dev/null +++ b/examples/Hello/Makefile @@ -0,0 +1,29 @@ + +top_srcdir=../.. + +default: libhello.so Hello.xml Hello.exe + +libhello.so: Hello.cpp Hello.h + $(CXX) -fPIC --shared -o $@ Hello.cpp + +Hello.xml: Hello.h + gccxml -fxml=$@ Hello.h + +output gen: + $(RM) -r output + mono $(top_srcdir)/src/generator/bin/Debug/generator.exe -f=Hello.xml -ns=Hello -lib=hello + +INTEROP_DLL = \ + $(top_srcdir)/src/Mono.VisualC.Interop/bin/Debug/Mono.VisualC.Interop.dll + +HelloBinding.dll: output + mcs -out:$@ -target:library -r:$(INTEROP_DLL) output/*.cs + +Hello.exe: HelloBinding.dll Hello.cs + mcs -out:$@ -target:exe -r:$(INTEROP_DLL) -r:HelloBinding.dll Hello.cs + +clean: + $(RM) -r output libhello.so Hello.xml Hello.exe HelloBinding.dll + +run: Hello.exe + MONO_PATH=$(top_srcdir)/src/Mono.VisualC.Interop/bin/Debug mono Hello.exe \ No newline at end of file