none
unresolved external symbol __report_rangecheckfailure

    Question

  • Hey everyone. I'm trying to compile some source code using the libpng library. I get the following error during linking:

    1>g:\programming\png_encoder\png_encoder\pngencode.cpp(48): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(234) : see declaration of 'fopen'
    1>libpng.lib(pngerror.obj) : error LNK2019: unresolved external symbol ___report_rangecheckfailure referenced in function _png_default_error
    1>libpng.lib(pngrutil.obj) : error LNK2001: unresolved external symbol ___report_rangecheckfailure
    1>libpng.lib(inftrees.obj) : error LNK2001: unresolved external symbol ___report_rangecheckfailure
    1>G:\Programming\PNG_Encoder\GnuWin32\src\libpng\1.2.37\libpng-1.2.37-src\projects\visualc71\Debug\PNG_Encoder.exe : fatal error LNK1120: 1 unresolved externals

    From what I know, that function is related to the compiler option /GS for doing stack protection. What I'm primarily curious about is why it's unresolved here. Additional info that may help answering is that I'm using VS 2012 and the solution is one that has been converted from 2010. Thanks in advance for the feedback.

    Monday, April 15, 2013 11:18 PM

Answers

  • Hi,

    Welcome here.

    I have not got your point about solution. Do you mean you recompile the lib project, or make a new project which invokes the lib and configure again?

    Fopen will not help us to figure out the buffer overrun, so that is recommended to use secure function.

    The unresolved external symbol dedicates that you have not provide the implementation of the ___report_rangecheckfailure function. To check out that you can try to new a simple project that will only call the lib function to see whether the problem is hidden in the lib project.

    Have a nice day.

    Regards,


    Elegentin Xie
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, April 17, 2013 8:12 AM
    Moderator

All replies

  • SOLUTION: For anyone else that gets this, I had to remake the project as a VS2012 project. If anyone has input as to why this behavior occurred feel free to explain; I'm still curious :-D
    Monday, April 15, 2013 11:26 PM
  • Hi,

    Welcome here.

    I have not got your point about solution. Do you mean you recompile the lib project, or make a new project which invokes the lib and configure again?

    Fopen will not help us to figure out the buffer overrun, so that is recommended to use secure function.

    The unresolved external symbol dedicates that you have not provide the implementation of the ___report_rangecheckfailure function. To check out that you can try to new a simple project that will only call the lib function to see whether the problem is hidden in the lib project.

    Have a nice day.

    Regards,


    Elegentin Xie
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, April 17, 2013 8:12 AM
    Moderator
  • In the Solution Explorer, look at the project that you're linking (not the library) and see if the entry is marked "(Visual Studio 2010)".  If so, they you will have to choose between updating that project to Visual Studio 2012 (or later) or turning off compiler option /GS (Buffer Security Check) in that project and all of the libraries from which it pulls in code.

    Normally in Visual Studio 2012, the linker uses the "Microsoft Visual Studio 11.0" C libraries.  However, if your project is identified as "(Visual Studio 2010)", the linker uses the "Microsoft Visual Studio 10.0" instead.

    In Visual Studio 2012 and later, the /GS option generates calls to __report_rangecheckfailure.  (See http://blogs.msdn.com/b/sdl/archive/2012/01/26/enhancements-to-gs-in-visual-studio-11.aspx for a detailed description.)  In the "Microsoft Visual Studio 11.0" libraries, __report_rangecheckfailure, is in msvcrt[d].lib, but it does not appear at all in the "Microsoft Visual Studio 10.0" libraries.  Hence, a "(Visual Studio 2010)" project that uses code built with /GS under Visual Studio 2012 will get an unresolved external reference to __report_rangecheckfailure.

    So, your choices are to upgrade your project to Visual Studio 2012 (from the main menu Project | Upgrade VC++ projects…) or to forgo compiler option /GS (in the project's Property Pages, select Configuration Properties | C/C++ | Code Generation, and set Buffer Security Check to No (/GS-).)

    Dan Konigsbach Interoperability Architect DR Systems, Inc.


    • Edited by Dan Konigsbach Thursday, July 18, 2013 11:46 PM Improved formatting a bit
    Thursday, July 18, 2013 11:32 PM
  • Hi all,

    I had the same error when porting log4cxx from Visual Studio 2010 to Visual 2013.

    In Visual Studio 2010, we were using the Windows 7.1 SDK compiler. (Projet Properties, Configuration Properties, General, Platform toolset: Windows7.1SDK).

    When I ported my 4 projects (3 libs and 1 dll) to VS 2013, I changed the platform toolset for "Visual Studio 2013 (v120)" for all libs, but I forgot to do it for the dll. Then, I got the link error "unresolved external symbol __report_rangecheckfailure"...

    When I fixed the platform toolset of the dll to "Visual Studio 2013 (v120)", the link error disappeared.

    Serge Malo

    Senior Software Engineer

    Averna Technologies Inc.

    Wednesday, April 9, 2014 4:45 PM