.DEF文件的C / C ++的DLL [英] .def files C/C++ DLLs

查看:184
本文介绍了.DEF文件的C / C ++的DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不理解使用.DEF文件,DLL文件点。

I am not understanding the point of using .def files with DLLs.

看来,它取代了需要你的DLL code(即明确__declspec(dllexport)的),但是我无法生成不使用这些时,一个lib文件,然后创建链接的问题后,当内使用明确的出口使用DLL。

It seems that it replaces the need to use explicit exports within your DLL code (ie. explicit __declspec(dllexport)) however I am unable to generate a lib file when not using these which then creates linker issues later when using the DLL.

那么,你如何与客户端应用程序连接时使用.defs,不会取代需要使用页眉或文件的.lib?

So how do you use .defs when linking with the client application, do they replace the need to use a header or .lib file?

推荐答案

我的理解是,.DEF文件提供给__declspec(dllexport)的语法的替代,具有能够明确指定出口的序号额外的好处功能。如果你只通过序出口的一些功能,而不会显示有关函数本身尽可能多的信息,这非常有用(如:许多操作系统内部DLL的导出函数只能由序)。

My understanding is that .def files provide an alternative to the __declspec(dllexport) syntax, with the additional benefit of being able to explicitly specify the ordinals of the exported functions. This can be useful if you export some functions only by ordinal, which doesn't reveal as much information about the function itself (eg: many of the OS internal DLL's export functions only by ordinal).

查看参考页

请注意,在DEF文件的名称必须以二进制的名称相匹配。所以,如果你使用C或C ++用'的externC{...},名称不会错位;否则,你必须使用正确的错位的名称用于生成的DLL编译器的特定版本。该__declspec()函数这一切都是自动。

Note that the names in the .def file must match the names in the binary. So if you using C or C++ with 'extern "C" { ... }', the names will not be mangled; otherwise you must use the correct mangled names for the specific version of the compiler used to generate the DLL. The __declspec() function does this all automatically.

这篇关于.DEF文件的C / C ++的DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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