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

问题描述

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

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

麻烦的是,编译xlsLib时,我给出了一个.a文件(由MinGW生成的GCC静态库).但是,我的应用程序依赖于仅使用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运行时库properties of C/C++->Code Generation->Runtime Library可能会发生问题,但这取决于与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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 22:50