Mingw 的损坏/导出问题
我正在 Windows 下使用 Netbeans 和 MinGW 开发共享 C++ DLL。
我的第一个问题是:MinGW 和 Microsoft Visual C++ 之间的重整会有所不同吗? 我读到重整是特定于编译器的 - 这是真的吗?我需要使用 MinGW 获得与使用 MVC++ 相同的修改,这可能吗?
我发现,使用 Dependency Walker,导出的函数也被视为 C(并且它们在我的代码中没有导出为 C)。这是否取决于 DepWalker 的限制,或者由于某种原因 MinGW 使我的库导出为 C? (我验证了使用“export C”我不再看到损坏,而没有,我看到名称损坏(这与我基于 MVC++ 的预期不同),但我仍然看到“C”图标而不是“C++” ”。
这是链接命令:
g++.exe -static-libgcc -static-libstdc++ -shared -o my.dll -s 1.o 2.o ... no other.dll -static
谢谢提前致以最诚挚的问候。
I'm working on a shared C++ DLL using Netbeans and MinGW under Windows.
My first question is: will mangling be different between MinGW and Microsoft Visual C++?
I read that mangling is compiler specific - is it true? I need to obtain using MinGW the same mangling which I would have with MVC++, will this ever be possibile?
I discovered, using Dependency Walker, that the functions which are exported are also seen as C (and they are not exported as C in my code). Does this depends on a limitation of DepWalker or for some reason MinGW is making my library exporting as C? (I verified that using "export C" I don't see mangling anymore, while without, I see name mangling (which is different from what I was expecting based on MVC++) but I still see the "C" icon instead of "C++".
Here's the linking command:
g++.exe -static-libgcc -static-libstdc++ -shared -o my.dll -s 1.o 2.o ... n.o other.dll -static
Thank in advance and best regards.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,名称修改是特定于编译器的。它甚至可能在同一编译器的不同版本之间发生变化。
您永远不应该对损坏抱有任何期望,并且应该将其视为黑匣子 - 永远不要依赖它相同或不同。
如果您需要编译器间链接,请使用
extern "C"
。Yes, name mangling is compiler-specific. It could even change between versions of the same compiler.
You should never expect anything about mangling and should treat it as a black box - never rely on it to be the same or different.
If you need inter-compiler linkage use
extern "C"
.