// dll.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "iostream.h"
_declspec(dllexport) int add(int a,int b)
{
return a+b;
}
_declspec(dllexport) int sub(int a,int b)
{
return a-b;
}
_declspec(dllexport) int mul(int a,int b)
{
return a*b;
}
_declspec(dllexport) void print(int a,int b)
{
cout<<"Fuck,XXXXX"<<endl;
}
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
// main.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream.h"
#pragma comment(lib,"dll.lib")
extern int add(int a,int b);
extern int sub(int a,int b);
extern int mul(int a,int b);
extern void print(int a,int b);
int main(int argc, char* argv[])
{
cout<<add(1,2)<<endl;
cout<<sub(1,2)<<endl;
cout<<mul(1,2)<<endl;
print(1,2);
printf("Hello World!\n");
return 0;
}
//在动态链接库编译执行完成以后,把生成的dll文件和lib文件拷贝到main函数的目录的Debug前一级目录中,否则会出现无法打开lib文件的情况