Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do libraries compiled with MinGW work with MSVC?

Problem:
I would use a MinGW library in Visual Studio project.

How my system is built:

I downloaded ZBar library for my Windows 10 system ( zbar-0.23.91-win_x86_64-DShow.zip
This is the link: https://linuxtv.org/downloads/zbar/binaries/).

I have these files in the folder of lib and bin:

  • libzbar.a
  • libzbar.dll.a
  • libzbar.la
  • libzbar-0.dll

Error when build:
error LNK2019: unresolved external symbol __mingw_vsnprintf referenced in snprintf

My question
Do libraries compiled with MinGW work with MSVC?

like image 295
EliaTolin Avatar asked Mar 14 '26 12:03

EliaTolin


2 Answers

No, libraries compiled on MinGW can't be used with MSVC. The main reasons are:

  • Lack of ABI compatibility. That is to say that in binary, the way things can be laid out are different depending on the compiler.
  • Difference in how the standard library is implemented. The standard library can be implemented in many ways. The C++ Standard just says how functions should behave and does not force compiler developers to implement them in the same way.

In general, things compiled with one compiler aren't compatible with another compiler.

like image 135
StandingPad Animations Avatar answered Mar 17 '26 00:03

StandingPad Animations


The problem is that the libraries have been compiled with mingw while I need to compile them in an mscv project.

The solution was to rebuild the library with Visual Studio.

It was possible to use everything without problems.

like image 27
EliaTolin Avatar answered Mar 17 '26 02:03

EliaTolin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!