从lib生成def [英] Generate def from lib

查看:58
本文介绍了从lib生成def的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我已经有导入库是否可以从中创建一个 .def 文件?这与您通常要做的事情相反-通常您创建导入库来自 .def 文件.有什么办法可以做相反的事情吗?

If I already have an import library is there a way to create a .def file from it? This is backwards from the normal thing you'd do - normally you create an import library from a .def file. Is there any way to do the opposite?

推荐答案

可能-Microsoft工具 dumpbin/exports< lib文件> 可以打印静态库中驻留的符号类型.

It's possible - Microsoft tool dumpbin /exports <lib file> can print what kind of symbols reside in static library.

但是符号大多被弄乱了.

But symbols are mostly mangled.

您可以使用其他python脚本过滤掉以确定要导出的内容和不导出的内容.

You can use additional python script to filter out to determine what you want to export and what not to export.

这对于功能非常有效,但目前不适用于数据.

This works quite well for functions, but does not work well for data at the moment.

这里是一个示例存储库:

Here is one sample repository:

https://github.com/tapika/test_lib2def

可以为您演示其工作原理.

Which can demo you how it works.

我猜想对于大型库建议采用这种方式导出,此后可以更改导出/不导出,而无需再次重新编译所有库.(例如,可以基于名称空间或其他属性)

I guess exporting this way is recommended for huge size libraries, where export/not to export can be changed afterwards without the need to recompile all libraries again. (E.g. detection of what to export could be based on namespace or other attributes)

如果您是从头开始开发库,并且对要导出的内容和不导出的内容充满信心-那么使用普通的 __ declspec(dllimport | dllexport)会更容易,更好.

If you're developing library from scratch and you're confident on what you export and what not export - then easier and better to use normal __declspec(dllimport|dllexport).

这篇关于从lib生成def的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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