C ++ DLL导出:Decorated / Mangled名称 [英] C++ DLL Export: Decorated/Mangled names

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

问题描述

使用模块定义文件(MyDLL.def)创建基本C ++ DLL和导出的名称。
编译之后,我使用 dumpbin.exe检查导出的函数名称。
我希望看到:

Created basic C++ DLL and exported names using Module Definition file (MyDLL.def). After compilation I check the exported function names using dumpbin.exe I expect to see:

SomeFunction

p>

but I see this instead:

SomeFunction = SomeFunction@@@23mangledstuff#@@@@

为什么?

导出的函数出现无装饰(特别是与不使用Module Def文件相比)与其他东西?

The exported function appears undecorated (especially compared to not using the Module Def file), but what's up with the other stuff?

如果我使用 dumpbin.exe 从任何商业应用程序的DLL,你会得到清洁:

If I use dumpbin.exe against a DLL from any commercial application, you get the clean:

SomeFunction

而没有别的...

我也尝试删除模块定义并使用C导出样式导出名称,即:

I also tried removing the Module Definition and exporting the names using the "C" style of export, namely:

extern "C" void __declspec(dllexport) SomeFunction();

(仅使用externC未创建导出函数)

(Simply using "extern "C" did not create an exported function)

但是,这仍然创建相同的输出,即:

However, this still creates the same output, namely:

SomeFunction = SomeFunction@@@23mangledstuff#@@@@



我还尝试了 #define dllexport __declspec dllexport)选项,并创建了一个没有问题的LIB。但是,我不想在C#应用程序中为使用DLL的人提供LIB文件。

I also tried the #define dllexport __declspec(dllexport) option and created a LIB with no problem. However, I don't want to have to provide a LIB file to people using the DLL in their C# application.

这是一个简单的C ++ DLL(非托管代码),用C ++编译只有一个简单的头和代码。没有模块定义我得到错误的导出函数(我可以创建一个静态库和使用LIB没有问题如果我使用 externC__declspec(dllexport) 模块定义我得到什么出现是一个未装饰的函数名...唯一的问题是它后面是一个=和什么看起来像功能的装饰版本。我想摆脱=后的东西 - 或至少理解为什么它在那里。

It's a plain vanilla C++ DLL (unmanaged code), compiled with C++ nothing but a simple header and code. Without Module Def I get mangled exported functions (I can create a static library and use the LIB no problem. I'm trying to avoid that). If I use extern "C" __declspec(dllexport) OR a Module Definition I get what appears to be an undecorated function name... the only problem is that it is followed by an "=" and what looks like a decorated version of the function. I want to get rid of the stuff after the "=" - or at least understand why it is there.

按照原样,我可以肯定的是,我可以使用P / Invoke从C#调用函数...我只是想避免那个垃圾在结束的=。

As it stands, I'm pretty certain that I can call the function from C# using a P/Invoke... I just want to avoid that junk at the end of the "=".

我打开了关于如何更改项目/编译器设置的建议,但我只是使用标准的Visual Studio DLL模板 - 没有什么特别的。

I'm open to suggestions on how to change the project/compiler settings, but I just used the standard Visual Studio DLL template - nothing special.

推荐答案

您可以通过关闭调试信息生成来获得所需的内容。项目+属性,链接器,调试,生成调试信息=

You can get what you want by turning off debug info generation. Project + Properties, Linker, Debugging, Generate Debug Info = No.

当然,您只想为发布版本执行此操作。其中选项已经设置了这种方式。

Naturally, you only want to do this for the Release build. Where the option is already set that way.

这篇关于C ++ DLL导出:Decorated / Mangled名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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