How can I convert a VSTS .lib to a MinGW .a?

2019-01-26 15:04发布

问题:

I have a static library compiled with Visual Studio and I want to link to it from MinGW.

I tried changing the suffix but I get a bunch of warnings like: Warning: .drectve /DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized.

Also a few errors including: ./libetpan.a(Release_ssl/mailimap.obj):(.text[_mailimap_noop]+0x7): undefined reference to___security_cookie'`.

Any help is greatly appreciated.

回答1:

You can try to convert the .lib to .a with

http://code.google.com/p/lib2a/



回答2:

.lib and .a are not the same format. Changing the file extension is lying to the linker, which is why it isn't working.

If it is a 32-bit library you are trying to link, it should "just work." MinGW supports 32-bit .lib files. If it doesn't, file a bug report.

If it is a 64-bit library, and you are using MinGW-w64 or something based on it (like the TDM-GCC 64-bit version) see the MinGW-w64 FAQ entry:

gendef mylib.dll
dlltool --as-flags=--64 -m i386:x86-64 -k --output-lib libmylib.a --input-def mylib.def