且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从MinGW静态库(.a)到Visual Studio静态库(.lib)

更新时间:2023-11-13 16:56:16

使用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.