6

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?

Mario Petrovic
  • 7,500
  • 14
  • 42
  • 62
EliaTolin
  • 526
  • 3
  • 15

4 Answers4

7

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.

1

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.

EliaTolin
  • 526
  • 3
  • 15
0

You can use C-lion because It has direct support of MinGW. A sample tutorial for how to select MinGW as a toolchain in C-lion is given in this link.

https://www.jetbrains.com/help/clion/how-to-create-toolchain-in-clion.html#custom-targets-toolchain

enter image description here

Using this you will have direct access to all the libraries available for MinGW directly.

Abdul ahad
  • 1,383
  • 7
  • 18
0

No it can't. A library compiled with MinGW will only work with MinGW. You need to compile it from source code with MSVC.
I haven't used windows much and hardly used visual studio. But you can use MinGW on visual studio ide if you want.
Using MinGW with Visual Studio IDE

Keshav Sahu
  • 98
  • 2
  • 8