1.1文件——新建——项目,选择如下图
1.2新建头文件test.h和源文件test.c
//test.h
__declspec(dllexport) int sum(int a, int b);
//test.c
#include "test.h"
#include
int sum(int a, int b) {
return a + b;
}
1.3右击项目选择生成,在debug中会产生多个文件,我们只需要dllgen.dll和dllgen.lib
//main.c
#include "test.h"
#include
#include
#pragma comment(lib,"dllgen.lib")
void main() {
int n;
n = sum(10, 6);
printf("10 + 6 = %d\n",n);
system("pause");
}
2.4运行项目,查看测试结果