This project has moved and is read-only. For the latest updates, please go here.

veracrypt.sys: Build error on Windows 7 (missing __chkstk)

Topics: Technical Issues
Aug 28, 2016 at 9:10 AM
I've downloaded the latest version of the source code and i'm trying to build it on Windows 7 as described in the file. On the first step (driver building) I have the following errors messages:
3>------ Rebuild All started: Project: Crypto, Configuration: Debug Win32 ------
2>Build started 8/28/2016 9:38:21 AM.
2> ------ Cleaning veracrypt.sys: Debug x86 ------
3>Build started 8/28/2016 9:38:22 AM.
2> ------ Cleaning veracrypt.sys: Debug x64 ------
2> ------ Rebuilding veracrypt.sys: Debug x86 ------
2> BUILD: Compile and Link for x86
2> BUILD: Start time: Sun Aug 28 09:38:37 2016
2> BUILD: Examining c:\users\oc\devs\veracrypt\src\driver directory for files to compile.
2> c:\users\oc\devs\veracrypt\src\driver
2> BUILD: Compiling and Linking c:\users\oc\devs\veracrypt\src\driver directory
2> Compiling resources - driver.rc
2> 1>errors in directory c:\users\oc\devs\veracrypt\src\driver
2>1>c:\users\oc\devs\veracrypt\src\driver\crypto.lib(sha2.obj) : error LNK2019: unresolved external symbol __chkstk referenced in function __sha512_compile@4 2>1>c:\users\oc\devs\veracrypt\src\driver\obj_driver_debug\i386\veracrypt.sys : error LNK1120: 1 unresolved externals
2> BUILD: Finish time: Sun Aug 28 09:38:41 2016
2> BUILD: Done
2> 1 file compiled - 2 Errors
2> ------ Rebuilding veracrypt.sys: Debug x64 ------
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(43,5): error MSB3073: The command "echo ------ Rebuilding veracrypt.sys: Debug x86 ------
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(43,5): error MSB3073: cmd.exe /c BuildDriver.cmd -rebuild -debug -x86 "C:\Users\oc\Devs\VeraCrypt\src\Common" "C:\Users\oc\Devs\VeraCrypt\src\Crypto" "C:\Users\oc\Devs\VeraCrypt\src\Driver\"
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(43,5): error MSB3073: if errorlevel 1 exit %errorlevel%
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(43,5): error MSB3073: echo.
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(43,5): error MSB3073: echo ------ Rebuilding veracrypt.sys: Debug x64 ------
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(43,5): error MSB3073: BuildDriver.cmd -rebuild -debug -x64 "C:\Users\oc\Devs\VeraCrypt\src\Common" "C:\Users\oc\Devs\VeraCrypt\src\Crypto" "C:\Users\oc\Devs\VeraCrypt\src\Driver\"" exited with code -1.
2>Build FAILED.
2>Time Elapsed 00:00:40.53

I've no success trying to fix it using information found by google, what is going wrong ? I've understand the origin of the probleme using the MSDN knowledge base but not how to fix it,
can anyone help me please ?

Thank you very much for any help that you will bring me.

Best regards,

Aug 28, 2016 at 12:14 PM

This issue happens only when building the DEBUG version of VeraCrypt driver: as explained by this MSDN entry, _chkstk routine is called by the compiler when the local variables exceed 4K bytes in 32-bit build and 8K in 64-bit. In our case, the DEBUG build of 32-bit VeraCrypt driver triggers this because the function sha512_compile in Sha2.c uses more 4K bytes of stack when compiled in 32-bit DEBUG.

Unless you really need the DEBUG version of 32-bit VeraCrypt driver, it is advises to build only the RELEASE version of the VeraCrypt driver and in this case there will be no error since the stack use will be much lower.

If you just need to build VeraCrypt binaries (.exe) in DEBUG without the driver, then remove the driver from the DEBUG configuration and during your testing, deploy the RELEASE version of the driver alongside the other DEBUG .exe binaries.

For now, there is no plan to rewrite the function sha512_compile to solve this 32-bit DEBUG build issue since this case is never needed during development and testing, the cost of such modification is too high compared to its need.
Aug 30, 2016 at 10:34 PM

Thank you very much for your quick answer, especially because its author, I'm very honored ! :)
This confirms what I've found and understood, I had tried then to circumvent the problem quickly before giving up and tell me that I was wrong...
Rebuilds successfull in release mode, many thanks.
Now i've to understand how it works ;) and then hopefully propose you a few patchs later.

Best regards,