NO.1 使用DEF文件:
//dllsingle.h
#i nclude <windows.h>
INT APIENTRY add(int a,int b);
//dllsingle.cpp
#i nclude "dllsingle.h"
BOOL APIENTRY Entry()
{
return true;
}
INT APIENTRY add(int a,int b)
{
return a + b;
}
//dllsingle.def
LIBRARY dllsingle.dll
EXPORTS
add
//compile bat file
cl dllsingle.cpp dllsingle.def /link /out:dllsingle.dll /dll /Entry:Entry /OPT:NOWIN98 /machine:x86
del dllsingle.exp dllsingle.obj
pause
NO.2 不使用DEF文件
//dllsingle1.h
extern "C" _declspec(dllexport) int add(int a, int b);
//dllsingle.cpp
#i nclude "dllsingle1.h"
int Entry()
{
return 1;
}
int add(int a,int b)
{
return a + b;
}
//compile
cl dll2.cpp /link /out:dll2.dll /dll /Entry:Entry /OPT:NOWIN98 /machine:x86
del dll2.exp dll2.obj
pause
//dllsingle.h
#i nclude <windows.h>
INT APIENTRY add(int a,int b);
//dllsingle.cpp
#i nclude "dllsingle.h"
BOOL APIENTRY Entry()
{
return true;
}
INT APIENTRY add(int a,int b)
{
return a + b;
}
//dllsingle.def
LIBRARY dllsingle.dll
EXPORTS
add
//compile bat file
cl dllsingle.cpp dllsingle.def /link /out:dllsingle.dll /dll /Entry:Entry /OPT:NOWIN98 /machine:x86
del dllsingle.exp dllsingle.obj
pause
NO.2 不使用DEF文件
//dllsingle1.h
extern "C" _declspec(dllexport) int add(int a, int b);
//dllsingle.cpp
#i nclude "dllsingle1.h"
int Entry()
{
return 1;
}
int add(int a,int b)
{
return a + b;
}
//compile
cl dll2.cpp /link /out:dll2.dll /dll /Entry:Entry /OPT:NOWIN98 /machine:x86
del dll2.exp dll2.obj
pause