1

This is a win32 application that is being compiled with VS2017 (v141) with the following settings:

  • Use MFC in a Static Library
  • Use Multi-Byte Character Set

when it is compiled in VS2017, it gave this error. I've tried some solution posted online, but it is not working for me.

For Comment
  • 1,139
  • 4
  • 13
  • 25
  • While I appreciate that question, but that question is just too generic. – For Comment Jun 08 '19 at 04:13
  • The function is defined inline in a .h file. Which doesn't work so well when you don't #include that file, it isn't exactly obvious that you should. Linking legacy_stdio_definitions.lib is the well-known workaround. The other is to `#include ` so the function is defined. – Hans Passant Jun 08 '19 at 10:55
  • @HansPassant thanks for the suggestion, I added `#include ` in the `StdAfx.h` file, which is included in all of the files that has `printf` and `fprintf` statements, but it is still complaining. I'll look at how to link the `legacy_stdio_definitions.lib`. – For Comment Jun 08 '19 at 19:33
  • @HansPassant, ok, I just tried adding the `legacy_stdio_definitions.lib` to the linker as stated in [this could not find legacy_stdio_definitions.lib question](https://stackoverflow.com/questions/51816629/lnk1104cannot-open-file-legacy-stdio-definitions-lib), and it did work! **BUT** it also says that this is a hack, we should add the `stdio.h` header in proper places, but I've already included it in all code with `printf` and `fprintf` in my program, but it is still complaining. – For Comment Jun 08 '19 at 20:01
  • Using VS2015 to recompile a legacy Visual Studio C++ 6.0 ODBC driver for SQLite, I ran into this same problem. I had to use two additional libraries, `legacy_stdio_definitions.lib` and `legacy_stdio_wide_specifiers.lib` in order to link successfully. I really wish I knew why I was seeing this error with this build using `odbccp32.lib`. Reading about, it may be due to improper `odbccp32.lib` version. I had to also change `msvcrt.lib` to `msvcrt.lib vcruntime.lib ucrt.lib` for the .dll build due to this issue, https://stackoverflow.com/questions/34285476/memcmp-linker-error-visual-studio-2015 – Richard Chambers Oct 08 '21 at 06:45

0 Answers0