从使用 stdcall 的 DLL 创建 MSVC 导入库
我有一个导出的
extern "C" __declspec(dllexport) int __stdcall Foo( void );
dll DLL 的转储显示
******************************************************************************
Section: Exports
File Offset: 00001400 (5120)
Flags: 00000000
Time Stamp: 00000000
Major Version: 0000
Minor Version: 0000
Exports from simple.dll
3 exported name(s), 3 export addresse(s). Ordinal base is 1.
Sorted by Name:
RVA Ord. Hint Name
-------- ---- ---- ----
00002104 3 0000 std::nothrow
00001258 2 0001 Foo
000020F8 1 0002 ___CPPdebugHook
******************************************************************************
我从以下 def 文件开始:
LIBRARY simple.dll
EXPORTS
Foo
这创建了一个具有以下导出的 lib 文件:
Exports
ordinal name
_Foo
当我链接到此库时,msvc 链接器抱怨它找不到 _Foo@0 。为了解决这个问题,我向 def 文件添加了一个别名。
LIBRARY simple.dll
EXPORTS
Foo
Foo@0=Foo
这会产生一个带有导出的 lib 文件
Exports
ordinal name
_Foo
_Foo@0
现在项目链接没有任何问题。但是,当我尝试运行它时,我收到消息
“无法在动态链接库 simple.dll 中找到过程入口点 Foo@0”
所以看来,即使我告诉 lib.exe Foo@0 是Foo 的别名,它仍然创建一个尝试按名称加载“Foo@0”的导入库。
当我请求“Foo@0”时,有没有办法让导入库加载“Foo”?
谢谢,
大卫
I have a dll that exports
extern "C" __declspec(dllexport) int __stdcall Foo( void );
A dump of the dll shows
******************************************************************************
Section: Exports
File Offset: 00001400 (5120)
Flags: 00000000
Time Stamp: 00000000
Major Version: 0000
Minor Version: 0000
Exports from simple.dll
3 exported name(s), 3 export addresse(s). Ordinal base is 1.
Sorted by Name:
RVA Ord. Hint Name
-------- ---- ---- ----
00002104 3 0000 std::nothrow
00001258 2 0001 Foo
000020F8 1 0002 ___CPPdebugHook
******************************************************************************
I started with the following def file:
LIBRARY simple.dll
EXPORTS
Foo
This created a lib file with the following exports:
Exports
ordinal name
_Foo
When I link with this library, the msvc linker complains that it can't find _Foo@0. To correct this problem, I added an alias to the def file.
LIBRARY simple.dll
EXPORTS
Foo
Foo@0=Foo
Which results in a lib file with exports
Exports
ordinal name
_Foo
_Foo@0
Now the project links without any problem. However, when I try to run it, I get the message
"The procedure entry point Foo@0 could not be located in the dynamic link library simple.dll"
So it appears that even though I told lib.exe that Foo@0 is an alias for Foo, it still creates an import library that tries to load "Foo@0" by name.
Is there a way to get the import library to load "Foo" when I asked for "Foo@0"?
Thanks,
David
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您尝试使用别名的想法是正确的......
不使用别名,而是使用序数:(用你的例子):
为我工作:)
You had the right idea trying to use an alias ...
Instead of using an alias use an ordinal: (using your example):
Worked for me :)