创建DLL项目
void foo() {
printf("foo");
}
DEF
LIBRARY
EXPORTS
foo @ 1
创建客户项目
void foo();
int _tmain(int argc, _TCHAR* argv[])
{
foo();
return 0;
}
客户端可执行文件的导入表。
导入表中缺少函数名称。
你能告诉我,有没有办法强制使用链接器使用函数名?
答案 0 :(得分:0)
创建第二个没有序号的导入库:
>type foo.names.def
LIBRARY foo.dll
EXPORTS
foo
>lib /nologo /def:foo.names.def /machine:x86
Creating library foo.names.lib and object foo.names.exp
用法示例:
>type test.c
void foo();
int main()
{
foo();
return 0;
}
>cl /nologo test.c /link foo.names.lib
test.c
>dumpbin /nologo /imports:foo.dll test.exe
Dump of file test.exe
File Type: EXECUTABLE IMAGE
Section contains the following imports:
foo.dll
40C108 Import Address Table
410AA0 Import Name Table
0 time date stamp
0 Index of first forwarder reference
0 foo
将此与您使用“原始”导入库时获得的结果进行对比:
>cl /nologo test.c /link foo.lib
test.c
>dumpbin /nologo /imports:foo.dll test.exe
Dump of file test.exe
File Type: EXECUTABLE IMAGE
Section contains the following imports:
foo.dll
40C108 Import Address Table
410AA0 Import Name Table
0 time date stamp
0 Index of first forwarder reference
Ordinal 1