1. Create a C++ Win32 Console Application
2. 在新建的工程中添加头文件CppDll.h,内容如下
#pragma once
#ifdef CPPDLL_EXPORTS
#define CPPDLL_EXPORTS __declspec(dllexport)
#else
#define CPPDLL_EXPORTS __declspec(dllimport)
#endif
CPPDLL_EXPORTS int Add(int a, int b);
3. 在工程中的CppDll.cpp文件中编辑,内容如下
// CppDll.cpp : Defines the exported functions for the DLL application.
//
#include "stdafx.h"
#include "CppDll.h"
int Add(int a, int b)
{
return a + b;
}
4. 添加一个Module-Definition File(.def),内容如下