Cryptopp: Crypto++ build error due to <stddef.h> on Windows

Created on 14 Jan 2019  路  6Comments  路  Source: weidai11/cryptopp

Builds on Windows seems to fail with an linker error when in recent versions of Crypto++, I have read the README.txt and could not find any further instructions on how to build it. As far as I know there my VS 2017 C++ setup is as standard as you can get.

  • Windows 10.0.15063
  • Building in Visual Studio 2017 15.9.5 using the provided solution file
  • Affected Crypto++ versions: 8.0, 7.0, 6.0
  • Working Crypto++ version: 5.6.5

Steps to reproduce:

  1. Download and unzip source for one of the affected Crypto++ versions
  2. Open cryptest.sln in VS 2017
  3. Rebuild the solution (or just cryptlib project), build configuration does not matter

Expected result: The solution should build as intended

Actual result:
The solution fail to build with the error:

Severity    Code    Description Project File    Line    Suppression State
Error   C1083   Cannot open include file: 'stddef.h': No such file or directory cryptlib    c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\cstddef 7   

Most helpful comment

I found the solution to the problem - Windows Universal CRT SDK must be installed.

Steps to fix the problem:

  • Modify the Visual Studio 2017 installation
  • Install Individual Component -> Windows Universal CRT SDK

All 6 comments

The issue above was on my work machine - tested to build Crypto++ 8.0 on my personal machine using the same steps and it worked as intended.

Will look into what difference there is between the setups.

I found the solution to the problem - Windows Universal CRT SDK must be installed.

Steps to fix the problem:

  • Modify the Visual Studio 2017 installation
  • Install Individual Component -> Windows Universal CRT SDK

Thanks @robinwassen,

That's kind of a weird build error in 2019. It does not seem like you should need a SDK to build with a standard header like <stddef.h> or <cstddef>. <stddef.h> is Posix, and it provides uintptr_t, size_t, ptrdiff_t and a few other types.

I wonder if there's anything we can do to avoid the build failure.


Here's the cause of the error in stdcpp.h:

#include <cstdlib>
#include <cstddef>
#include <cstring>
#include <climits>
#include <cmath>

// uintptr_t and ptrdiff_t
#if defined(__SUNPRO_CC)
# if (__SUNPRO_CC >= 0x5100)
#  include <stdint.h>
# endif
#elif defined(_MSC_VER)
# if (_MSC_VER >= 1700)
#  include <stdint.h>
# else
#  include <stddef.h>
# endif
#elif (__cplusplus < 201103L)
# include <stdint.h>
#endif

@noloader I am not sure it's worth mitigating this in Crypto++ when I saw what the solution was, if someone else bumps into this problem I guess this issue will show up on Google which should be enough.

But I agree that it's really odd that those header files was inaccessible, because I have built a lot of other C++ projects on the same machine.

It looks like someone else is having trouble: Compiling Crypto++ Library on Visual Studio 2017 Targeting Windows 10.

It is time to act.

@noloader Still had the same issue. After changing Visual Studio Installation as @robinwassen suggested the bug was fixed. So your fix didn't work for me (Win7, VS2017).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

guidovranken picture guidovranken  路  8Comments

ISmileYouCryYouSmileIDie picture ISmileYouCryYouSmileIDie  路  6Comments

kwizart picture kwizart  路  12Comments

alonbl picture alonbl  路  11Comments

asbai picture asbai  路  8Comments