|
Tutorial for an MC++ library with a native API |
|
In this tutorial the library will have just two sample
APIs, one for Console and one for GUI. Open Visual Studio .NET (2003) and create a new project, using the C++ template [Class Library (.NET)]:
then let's just add a simple .NET Windows Form, named MyMCppForm:
Now we define the native API in a .H header file, thus
in the project tree, click 'Add New Item',
use the classic well-known __declspec
techniques for import & export, Open the project settings, add the preprocessor-define MCPPLIB_BUILD:
In the project tree, click to insert a new item.
Add an EXPORTS section with the API names (exactly as in .h, non-decorated). Open the project settings, verify the .DEF file was added:
Finally, add some implementation source-code to the file MCppLib.cpp:
Rebuild the project. Done!
Important Please note the following issue: Mixed DLL loading problem KB -
Linker Warnings When You Build Managed Extensions for C++ DLL Projects |