在Visual Studio 2010中使用DEF从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?
我刚才找到了解决方案: 此处。
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:
- 告诉VS2010编译一个动态库(.dll)。
- 使用 (修饰的)名称(至少当您的语言是C ++时) 。如果您使用 dllexport ,您可以将.dll的已导出符号显示为。如果您尚未导出任何内容,请参见此帖子。 / li>
- 在属性页中将.def添加到库定义。
- 编译
- 验证您的工作是否正确,例如通过 Dependency Walker 打开相关文件,例如 .exe 。您应该在依赖项树中的依赖文件下方看到刚编译的库。应该没有错误或警告,例如。 没有红色。
- Tell VS2010 to compile a dynamic library (.dll). This is done in the Property Page of the library's project.
- 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.
- Add the .def to the library definition in its Property Page.
- Compile
- 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".