创建DLL动态链接库——模块定义法(def)
DLL模块定义法(Module-Definition File,即DEF):在VS家族IDE中,根据提示新增.def文件,如下:
LIBRARY 关键字;
mytestDll 库名;
DLL_ADD 需要导的函数名;
DLL_SUB 需要导的函数名;
DLL_MUL 需要导的函数名;
DLL_DIV 需要导的函数名;
DEF保留字:
APPLOADER1 |
INITINSTANCE2 |
PRELOAD |
BASE |
IOPL |
PRIVATE |
CODE |
LIBRARY1 |
PROTMODE2 |
CONFORMING |
LOADONCALL1 |
PURE1 |
DATA |
LONGNAMES2 |
READONLY |
DESCRIPTION |
MOVABLE1 |
READWRITE |
DEV386 |
MOVEABLE1 |
REALMODE1 |
DISCARDABLE |
MULTIPLE |
RESIDENT |
DYNAMIC |
NAME |
RESIDENTNAME1 |
EXECUTE-ONLY |
NEWFILES2 |
SECTIONS |
EXECUTEONLY |
NODATA1 |
SEGMENTS |
EXECUTEREAD |
NOIOPL1 |
SHARED |
EXETYPE |
NONAME |
SINGLE |
EXPORTS |
NONCONFORMING1 |
STACKSIZE |
FIXED1 |
NONDISCARDABLE |
STUB |
FUNCTIONS2 |
NONE |
VERSION |
HEAPSIZE |
NONSHARED |
WINDOWAPI |
IMPORTS |
NOTWINDOWCOMPAT1 |
WINDOWCOMPAT |
IMPURE1 |
OBJECTS |
WINDOWS |
INCLUDE2 |
OLD1 |
|
1 链接器在遇到此术语时发出警告(“忽略”)。不过,该保留字仍然保留。
2 链接器忽略该字,但是不发出警告。
用例如下:
通过以上三个文件即可编译出mytestDll.lib和mytestDll.dll两个库文件。