使用DEF从Visual Studio 2010中的DLL导出功能 [英] Export function from DLL in Visual Studio 2010 using DEF

查看:202
本文介绍了使用DEF从Visual Studio 2010中的DLL导出功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继承了一个具有许多动态库的巨大的C ++ 多项目解决方案,但是没有任何

I inherited a huge C++ multi-project solution with many dynamic libraries but without any

__declspec(dllexport)

已知不一定必须插入任何 dllexport (这将是很多工作),但可以使用一个 .def 文件,而不是相应的 .dll

I learned that one does not necessarily have to insert any dllexport (would be much work) but that one can use a .def file in addition to corresponding .dll instead.

为了尝试从这里,从标题中删除了 dllexport ,并且...拼命失败。按照引用的页面,我的关键问题是如何到

In order to try that I built a "DLL Hello World" project from here, removed the dllexport from the header and...failed desperately. In the words of already cited page, my key question is how to

"[..] use the .def file when building the DLL."

我的 .def 文件是(我只用添加方法):

My .def file is (I try the code only with the Add method):

LIBRARY   MathFuncsDll
EXPORTS 
?Add@MyMathFuncs@MathFuncs@@SANNN@Z

如何在Visual Studio 2010中按顺序构建DLL时如何使用它导出添加方法?

How do I use it when building the DLL in Visual Studio 2010 in order to export the Add method?

推荐答案

在这个问题出现半天之后,我刚刚找到了解决方案:描述了 here

After having passed half a day in front of this problem, I just found the solution: it is described here.

使用我自己的单词继续使用VS2010 中的 .def 文件恢复符号导出过程:

To resume the process of symbol export with .def files in VS2010 using my own words:


  1. 告诉VS2010编译动态库(.dll)。这可以在图书馆项目的属性页中完成。

  2. 使用 mangled (装饰)名称(至少当你的语言是C ++)。如果您使用 dllexport 您可以将.dll的已导出符号显示为这里描述。如果您尚未导出任何内容,请参阅信息。

  3. 将.def添加到属性页中的库定义。

  4. 编译

  5. 验证您的工作的正确性,例如 Dependency Walker ,打开依赖文件,例如 .EXE 。您应该在依赖文件下方的依赖关系树中看到刚刚编译的库。应该没有错误或警告,例如

  1. Tell VS2010 to compile a dynamic library (.dll). This is done in the Property Page of the library's project.
  2. Craft a module definition file (.def) by using mangled (decorated) names (at least when Your language is C++). If You make use of dllexport You can display already exported symbols of Your .dll as described here. If You haven't anything exported yet, see this post.
  3. Add the .def to the library definition in its Property Page.
  4. Compile
  5. Verify the correctness of Your work, for example with Dependency Walker by opening the dependent file, e.g. .exe. You should see the just compiled library in a dependency tree below the dependent file. There should be no errors or warnings, e.g. no red colour.

如果您有关于 .def 文件的其他问题,看看终端模块定义文件

If You have further questions concerning .def files, look out for the terminus "Module definition file".

这篇关于使用DEF从Visual Studio 2010中的DLL导出功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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