从 MinGW 静态库 (.a) 到 Visual Studio 静态库 (.lib) [英] From MinGW static library (.a) to Visual Studio static library (.lib)

查看:47
本文介绍了从 MinGW 静态库 (.a) 到 Visual Studio 静态库 (.lib)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 xlsLib 从 C++ 应用程序创建 Excel 电子表格.

I'm trying to use xlsLib for creating Excel spreadsheets from a C++ application.

麻烦的是,编译xlsLib,我给了一个.a文件(一个GCC静态库,由MinGW生成).但是,我的应用程序依赖于另一个只能使用 Visual Studio 编译的 API (PhysX).

The trouble is that compiling xlsLib, I give a .a file (a GCC static library, generated by MinGW). But, my application depends on another API (PhysX) that only compiles with Visual Studio.

因此:是否可以将 GCC 静态库(xlslib.a)转换为 Visual Studio 静态库文件(xlslib.lib)?

Thus: is it possible to transform the GCC static library (xlslib.a) to a Visual Studio static library file (xlslib.lib)?

推荐答案

使用 MinGW 生成的静态库存档通常与 Visual C++ 编译器/链接器兼容.因此,您应该能够通过将 .a 文件添加到 Visual Studio 项目属性中的链接器输入来直接使用它们:

The archives of static libraries generated with MinGW are generally compatible with Visual C++ compiler/linker. So, you should be able to use them directly by adding .a files to linker input in your project properties in Visual Studio:

  1. 转到项目Properties (Alt-F7).
  2. 在左侧框中,打开Configuration Properties->Linker->Input
  3. 添加您需要使用的所有 .a 档案的列表
  4. 您可能还需要添加 MinGW 的 libgcc.a
  1. Go to project Properties (Alt-F7).
  2. On the left box, open Configuration Properties->Linker->Input
  3. Add list of all .a archives you need to use
  4. You may need to add also MinGW's libgcc.a library

此外,混合C运行时库C/C++的属性->代码生成->运行时库可能会出现问题,但这取决于您与MinGW一起使用的构建配置.有时需要链接来自 MinGW 的 libmsvcrt.a,但在许多(如果不是大多数)情况下它会导致问题.

Also, there may occur problems regarding mixed C run-time libraries properties of C/C++->Code Generation->Runtime Library, but this depends on your build configuration you use with MinGW. Sometimes it is necessary to link against libmsvcrt.a from MinGW but in many (if not most) cases it causes problems.

最后,这种混合的 MinGW 和 Visual C++ 链接通常有效,但对于 C 模块而言,它不适用于 C++,据我所知.

Finally, this mixed MinGW and Visual C++ linking generally works but for C modules and it does not work for C++, as far as I know.

这篇关于从 MinGW 静态库 (.a) 到 Visual Studio 静态库 (.lib)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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