Convert from MinGW.a to VC ++. Lib

I have an old library (in C ++) that I can only use on MinGW + MSYS32 on Windows. From this, I can create a static .a library file created from GNU libtool. My main development is done in Visual Studio 2008. If I try to take the library created by MinGW and link it in Visual Studio, it complains about the lack of external ones. Most likely, this is due to the fact that this is done using the C ++ symbol, and that it does not match whats in the .a file. Is there any way to convert a static .a file to a VC ++ library format?

+4
source share
2 answers

If characters are spoiled in different ways, compilers use a different ABI, and you won’t be able to “convert” or something else to compiled libraries: names of reasons that are distorted in different ways deliberately avoid using users to create an executable file from object files using different ABI. ABI determines how arguments are passed, how virtual function tables are represented, how exceptions are thrown, the size of the underlying data types, and a host of other things. The name mangling is also part of this and carefully chosen to be effective and distinct from other ABIs on the same platform. The easiest way to check if a name change is really different is to compile a file with several functions using only basic types with both compilers and character lookings (on UNIX, I would use nm for this, m not a Windows programmer, and therefore I don't know which tool to use there).

Based on Wikipedia, it seems that MinGW also uses a different runtime library: the layout and implementation of the standard C ++ library ( libstdc ++ ) and Visual Studio ( Dinkumware ) are not compatible. Even if the ABI between the two compilers is the same, the standard C ++ library is not used. If the ABI is the same, you will need to replace the installed things so that one compiler uses the standard library of the corresponding other compiler. It is not possible to do this with an already compiled library. I do not know if this is possible.

Personally, I would not try to connect things between these two different compilers, because it should not work at all. Instead, you will need to transfer the implementation to the general compiler and go from there.

+3
source

Find the def file and run the command, for example. lib / machine: i386 / def: test.def it will generate a lib import file.

+2
source

Source: https://habr.com/ru/post/1397246/


All Articles