使用DEF文件而不是LIB文件链接到DLL? [英] Linking to a DLL with a DEF file instead of a LIB file?

查看:97
本文介绍了使用DEF文件而不是LIB文件链接到DLL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解到您可以:

  • 将.DLL文件转换为 .DEF 文件,其中包括其导出文件
    (这不适用于许多约定)
  • .DEF 文件转换为.LIB文件,您可以使用该文件链接到DLL
  • Convert a .DLL file into a .DEF file, which includes its exports
    ( This doesn't work with many conventions)
  • Convert a .DEF file into a .LIB file, which you can use to link to the DLL

为什么(大多数)链接器仅在给定 .DEF文件而不是.LIB文件的情况下链接到DLL?

Why can't (most) linkers link to a DLL given only a .DEF file, instead of a .LIB file?

推荐答案

最终,这里的答案是因为没有人非常想要它,它并没有真正的帮助".

Ultimately, the answer here is 'because noone wanted it badly enough and it doesn't really help anything'.

DEF文件是为DLL创建导入库的输入文件.然后,以后,当DLL被另一个链接使用时,importlib本身就是输入. importlib在外观上看起来很特殊,但是当您查看内部时,它实际上只是一个稍微特殊的lib,其中包含对象.

The DEF file is an input file that creates an import lib for the DLL. And then, later, when the DLL is being consumed by another link, the importlib is itself an input. The importlib looks like something special on the outside, but when you look at the inside it's really just a slightly special lib with objects in it.

完全有可能修改链接器以直接获取def文件(或DLL).

It totally would be possible to modify the linker to take a def file (or a DLL, for that matter) directly.

但是,链接器的设计中心是它将对象作为输入并输出PE可执行文件.因此,以DEF或DLL作为输入超出了设计模式.

But the design centre of the linker is that it takes objects as inputs and outputs a PE executable. So taking a DEF or DLL as an input goes outside the design pattern.

除此之外,它毫无意义-允许链接器将DEF文件或DLL作为输入不会启用任何重要的新方案,也不会将此功能排除在外.将您拥有的DEF文件(即使没有实际的DLL)转换为可用的importlib只需花费片刻时间(只需为每个DEF条目创建虚假的空函数并链接它).因此,没有理由添加直接链接DEF文件的功能.

Beyond that it'd be rather pointless - allowing the linker to take a DEF file or DLL as input would neither enable any important new scenarios, nor does leaving this feature out block anything. Converting a DEF file you have (even without the actual DLL) into a usable importlib is the work of a few moments (simply create fake empty function for each DEF entry and link that). So there's no reason to add the ability to link a DEF file directly.

Martyn

这篇关于使用DEF文件而不是LIB文件链接到DLL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆