none
Updated to VS 2015 and now get Unresolved External Errors

    Question

  • Hey All,

    I have been developing in C++ in around a year now and have started development on my own game engine as a on going project this school year.

    I have decided to use GLFW and GLEW as my OpenGL libraries for this project and it worked fine in VS 2013 when I added them through Properties > VC++ Development > Include/Library Directories and Linker > Input > Additional Dependencies. But now I have made the switch to Windows 10 and VS 2015 I keep getting unresolved externals when I build which never happened before!

    Hope I have provided enough detail and if you need anymore please let me know!

    Thanks for Any Help!

    Friday, August 7, 2015 4:24 PM

Answers

  • I agree with RLWA32, the undefined symbol is the most helpful information.

    In general, thought there were a number of breaking changes in VS2015 documented here:

    https://msdn.microsoft.com/en-us/library/bb531344.aspx

    In particular, for undefined   __vsnwprintf_s

    "The printf and scanf family of functions are now defined inline.                    

    The definitions of all of the printf and scanf functions have been moved inline into <stdio.h>, <conio.h>, and other CRT headers. This is a breaking change that leads to a linker error (LNK2019, unresolved external symbol) for any programs that declared these functions locally without including the appropriate CRT headers. If possible, you should update the code to include the CRT headers (that is, add #include <stdio.h>) and the inline functions, but if you do not want to modify your code to include these header files, an alternative solution is to add an additional library to your linker input, legacy_stdio_definitions.lib.

    To add this library to your linker input in the IDE, open the context menu for the project node, choose Properties, then in the Project Properties dialog box, choose Linker, and edit the Linker Input to add legacy_stdio_definitions.lib to the semi-colon-separated list."

    • Marked as answer by OhLawdDoge Friday, August 7, 2015 9:22 PM
    Friday, August 7, 2015 5:33 PM

All replies

  • Did you create a property page in VS2015 so that your project can find the OpenGL libraries in the LIB path?

    It would be helpful if you posted the linker error message so we could see which functions it could not find

    Friday, August 7, 2015 4:50 PM
  • I agree with RLWA32, the undefined symbol is the most helpful information.

    In general, thought there were a number of breaking changes in VS2015 documented here:

    https://msdn.microsoft.com/en-us/library/bb531344.aspx

    In particular, for undefined   __vsnwprintf_s

    "The printf and scanf family of functions are now defined inline.                    

    The definitions of all of the printf and scanf functions have been moved inline into <stdio.h>, <conio.h>, and other CRT headers. This is a breaking change that leads to a linker error (LNK2019, unresolved external symbol) for any programs that declared these functions locally without including the appropriate CRT headers. If possible, you should update the code to include the CRT headers (that is, add #include <stdio.h>) and the inline functions, but if you do not want to modify your code to include these header files, an alternative solution is to add an additional library to your linker input, legacy_stdio_definitions.lib.

    To add this library to your linker input in the IDE, open the context menu for the project node, choose Properties, then in the Project Properties dialog box, choose Linker, and edit the Linker Input to add legacy_stdio_definitions.lib to the semi-colon-separated list."

    • Marked as answer by OhLawdDoge Friday, August 7, 2015 9:22 PM
    Friday, August 7, 2015 5:33 PM
  • Thanks for the fast response Andrew,

    I started a fresh empty C++ project to test this evening and added the two libraries and i am getting alot of unresolved externals referring to _vsnprintf:

    • Error LNK2019 unresolved external symbol __imp__sscanf referenced in function _parseVersionString
    • Error LNK2001 unresolved external symbol __imp__vsnprintf
    • Error LNK2001 unresolved external symbol __imp__vsnprintf reference in function _glfwInputError

    Hope this helps and thanks again!

    Friday, August 7, 2015 7:13 PM
    • 3 Unresolved Externals
    • (Warning) defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
    • Error LNK2019 unresolved external symbol __imp__sscanf referenced in function _parseVersionString
    • Error LNK2001 unresolved external symbol __imp__vsnprintf
    • Error LNK2001 unresolved external symbol __imp__vsnprintf reference in function _glfwInputError
    • Error LNK2001 unresolved external symbol __imp__vsnprintf

    Hope this helps and thanks again!

    Friday, August 7, 2015 7:15 PM
  • I agree with RLWA32, the undefined symbol is the most helpful information.

    In general, thought there were a number of breaking changes in VS2015 documented here:

    https://msdn.microsoft.com/en-us/library/bb531344.aspx

    In particular, for undefined   __vsnwprintf_s

    "The printf and scanf family of functions are now defined inline.                    

    The definitions of all of the printf and scanf functions have been moved inline into <stdio.h>, <conio.h>, and other CRT headers. This is a breaking change that leads to a linker error (LNK2019, unresolved external symbol) for any programs that declared these functions locally without including the appropriate CRT headers. If possible, you should update the code to include the CRT headers (that is, add #include <stdio.h>) and the inline functions, but if you do not want to modify your code to include these header files, an alternative solution is to add an additional library to your linker input, legacy_stdio_definitions.lib.

    To add this library to your linker input in the IDE, open the context menu for the project node, choose Properties, then in the Project Properties dialog box, choose Linker, and edit the Linker Input to add legacy_stdio_definitions.lib to the semi-colon-separated list."

    Andrew gave the above suggestion and it makes a lot of sense to me.  I suggest you give his solution a try
    Friday, August 7, 2015 8:06 PM
  • Yeh i just had the chance to try it out and it worked fine with glfw think there is an issue with a preprocessor for glew atm but i can fix that!

    Thanks so much for all the help! :)

    Friday, August 7, 2015 9:23 PM
  •  >>legacy_stdio_definitions.lib.

    >>To add this library to your linker input in the IDE, open the context menu for the project node, >>choose Properties, then in the Project Properties dialog box, choose Linker, and edit the Linker Input >>to add legacy_stdio_definitions.lib to the semi-colon-separated list."

    *THANK YOU* Andrew for showing >> just where/how to do this!

    I had been entering it in other places.. and the linker command line was showing it as OK.

    This solves the LAST of 2 days of errors of migrating a large project to VS2015   : )    : )

    Thursday, September 24, 2015 2:54 AM
  • This worked, adding legacy_stdio_definitions.lib to the linker. Thanks

    Hector Santos, CTO Santronics Software, Inc. http://www.santronics.com

    Monday, May 16, 2016 6:25 PM
  • I agree with RLWA32, the undefined symbol is the most helpful information.

    In general, thought there were a number of breaking changes in VS2015 documented here:

    https://msdn.microsoft.com/en-us/library/bb531344.aspx

    In particular, for undefined   __vsnwprintf_s

    "The printf and scanf family of functions are now defined inline.                    

    The definitions of all of the printf and scanf functions have been moved inline into <stdio.h>, <conio.h>, and other CRT headers. This is a breaking change that leads to a linker error (LNK2019, unresolved external symbol) for any programs that declared these functions locally without including the appropriate CRT headers. If possible, you should update the code to include the CRT headers (that is, add #include <stdio.h>) and the inline functions, but if you do not want to modify your code to include these header files, an alternative solution is to add an additional library to your linker input, legacy_stdio_definitions.lib.

    To add this library to your linker input in the IDE, open the context menu for the project node, choose Properties, then in the Project Properties dialog box, choose Linker, and edit the Linker Input to add legacy_stdio_definitions.lib to the semi-colon-separated list."

    Adding the "legacy_stdio_definitions.lib" worked just fine. Thanks Andrew, for the solution!!

    Wednesday, August 17, 2016 10:45 AM
  • Hi,

    I am also facing same issue, I have included legacy_stdio_definitions.lib in Linker->Input project properties. I can find odbccp32.lib on my system but could not find legacy_stdio_definitions.lib.

    I have installed latest Windows 10 SDK 10.0.14393.0. but still getting linker error for __vsnwprintf_s

    Kindly can you let me know what I am missing?

    Thanks,

    Friday, September 2, 2016 10:35 AM
  • Check the LIB search path for your VC++ directories.  legacy_stdio_definitions.lib resides in the C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib folder (and subfolders).
    Friday, September 2, 2016 10:58 AM
  • Thanks, found the issue and fixed.
    Friday, September 2, 2016 11:24 AM
  • Is there any other possible way to fix this without changing the project? I mean, my team was not having the same issue in their machine. They don't have to do those project changes but they can build it successfully. There might be a settings in visual studio that I can update. 
    Friday, January 27, 2017 6:16 PM
  • Is there any other possible way to fix this without changing the project? I mean, my team was not having the same issue in their machine. They don't have to do those project changes but they can build it successfully. There might be a settings in visual studio that I can update. 

    From breaking changes docs -

    The definitions of all of the printf and scanf functions have been moved inline into <stdio.h>, <conio.h>, and other CRT headers. This is a breaking change that leads to a linker error (LNK2019, unresolved external symbol) for any programs that declared these functions locally without including the appropriate CRT headers. If possible, you should update the code to include the CRT headers (that is, add #include <stdio.h>) and the inline functions, but if you do not want to modify your code to include these header files, an alternative solution is to add an additional library to your linker input, legacy_stdio_definitions.lib.

    Friday, January 27, 2017 6:22 PM