Archived Forum Post

Index of archived forum posts

Question:

___report_rangecheckfailure unresolved external in VC11

Jul 18 '13 at 19:44

I am building the SFTP application and got the following err:

Error 2 error LNK2001: unresolved external symbol 
    ___report_rangecheckfailure E:/MyProjects/something/blahblah/blahblah/ChilkatRel.lib(ZeeDeflateState.obj)

The project is just the sample code to write text file over sftp.


Answer

See this MSDN web page:
http://blogs.msdn.com/b/sdl/archive/2012/01/26/enhancements-to-gs-in-visual-studio-11.aspx

Also see this:
http://blogs.msdn.com/b/sdl/archive/2011/12/02/security.aspx

The Chilkat C++ libs for Visual Studio 11 are compiled with the default settings, which includes the on-by-default /GS compiler switch, which provides protection against some memory safety bugs such as buffer overflows. The ___report_rangecheckfailure is not a Chilkat function, but is part of the Microsoft Platform SDK. It may be that compiling your app with the /GS compiler switch on will solve the problem.


Answer

Please try these new builds:
(32-bit) http://www.chilkatsoft.com/preRelease/chilkat-9.3.2-x86-vc11.zip
and
(64-bit) http://www.chilkatsoft.com/preRelease/chilkat-9.3.2-x86_64-vc11.zip

They are built without the /GS option and therefore the extra code (rangecheckfailure) added by the MSVC++ compiler shouldn't be present.


Answer

This is not specific to Chilkat, but is how I resolved this in another context. Perhaps it will be helpful to you, also.

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-).)