使用mingw和msys转换VC++库到 mingw 库?

发布于 2024-12-18 13:57:11 字数 42 浏览 4 评论 0原文

是否有关于如何通过 MinGW 工具链转换/使用 VC++ 库的指南?

Are there any guides on how to convert/use VC++ libraries with the MinGW toolchain?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

抚你发端 2024-12-25 13:57:11

看起来 MinGW 人员有一个关于此问题的常见问题解答页面

简短的回答:不是真的。

长答案:对于 DLL,也许吧。

Looks like the MinGW folks have a FAQ page about this.

Short answer: not really.

Long answer: For DLLs, maybe.

青春有你 2024-12-25 13:57:11

C 接口

如果库二进制接口作为仅 C 接口公开,并作为 .dll 提供,您可以在 mingw 编译的程序中使用 VC 库,无需任何转换(我不知道 VC .lib 文件是否是与 mingw 工具链兼容)。

C++ 接口

如果没有 C 级接口,则需要库的源代码,因为必须使用 g++ 编译库。原因是 g++ 和 VC 之间没有通用的 ABI1。

1ABI

ABI(应用程序二进制接口)定义了 C++ 的技术底层细节。它处理名称如何修改、函数如何调用、异常系统如何工作以及许多其他内容。 ABI 不是由 C++ 标准定义的,因此(几乎)每个编译器供应商都创建了自己的 ABI。这些 ABI 不可互换,因此您不能混合不同编译器生成的二进制文件(.o/.obj 和 .a/.lib 文件)。事实上,情况更糟糕,您甚至无法可靠地交换由一个编译器的不同版本创建的二进制文件,或者使用相同编译器但使用不同编译器选项创建的二进制文件(例如一个二进制文件带有异常处理,另一个二进制文件没有异常处理)。

C interface

If the library binary interface is exposed as a C only interface, and is provided as a .dll you can use the VC-library in a mingw-compiled program without any conversions (I don't know if VC .lib files are compatible with the mingw toolchain).

C++ Interface

If there is no C-level interface, you need the source code of the library, since you must compile the library with g++. The reason for this is that there is no common ABI¹ between g++ and VC.

¹ABI

The ABI (application binary interface) defines the technical low-level details of C++. It handles how names are mangled, how functions are called, how the exception system works and many other stuff. The ABI is not defined by the C++ standard, so (almost) every compiler vendor created its own. Those ABIs are not interchangeable, so you can't mix binaries (.o/.obj and .a/.lib files) produced by different compilers. In fact the situation is that worse, that you even can't reliable interchange binaries created by different versions of one compiler, or created with the same compiler, but with different compiler options(like one binary with, the other without exception handling).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文