In the previous section, we learned about cross-platform implementation, and how to Interop with existing native and Mono libraries. To demonstrate interoperability, we created small sample applications. Let's start with building our first native library in C++. Follow these steps:
- Open Visual Studio and select
Windows Desktop
underVisual C++
and select the project typeDynamic-Link Library (DLL)
. In this example, we name the projectExampleDLL
and provide the location where we want to create the project:
- Right-click on the header files folder and create a new header file. In this example, we named it
Calculate.h
. TheCalculate
header file contains mathematical operations such as the summation of two integer numbers, multiplication, and division:
#ifndef Calculate #define Calculate extern "C" { __declspec(dllexport)int Sum(int a, int b) { return a + b; } __declspec(dllexport) int Multiply(int number1, int number2) { int result = number1...