Use libraries compiled with visual studio in an application compiled by g++ (mingw)(在由 g++ (mingw) 编译的应用程序中使用使用 Visual Studio 编译的库)
问题描述
在windows上g++(mingw)编译的应用中是否可以使用visual studio编译的库?
Is it possible to use a library compiled by visual studio in an application compiled by g++ (mingw) on Windows?
推荐答案
如果库是用 C++ 编写并公开 C++ 接口:否(因为 g++ 和 VC++ 之间的名称修改不同).
If the library is written in C++ and exposes a C++ interface: no (because the name-mangling differs between g++ and VC++).
如果库是用 C 编写的静态库(或带有
extern "C"
接口):是,但有一些注意事项.If the library is a static library written in C (or with an
extern "C"
interface): yes, but certain caveats apply.如果库是带有 C 接口的 DLL:是的,但是你'必须创建自己的导入库.
If the library is a DLL with a C interface: yes, but you'll have to create your own import library.
这篇关于在由 g++ (mingw) 编译的应用程序中使用使用 Visual Studio 编译的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在由 g++ (mingw) 编译的应用程序中使用使用 Visual Studio 编译的库


基础教程推荐
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- CString 到 char* 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16