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?

0

4 Answers 4

7
+100

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.

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.

1
  • Unfortunately the project is compiled under MSVC compiler. I can't change compiler.
    – EliaTolin
    Jan 20, 2022 at 8:51
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

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.