AESlib Example does not compile

I have installed this library in Arduino IDE. When I tried to compile the “simple” example, I got the following error:

Arduino: 1.8.11 (Windows 10), Board: “WeMos D1 R1, 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), v2 Lower Memory, Disabled, WIFI, Only Sketch, 921600”

C:\Users\af\Documents\Arduino\libraries\AESLib\src\AESLib.cpp: In member function ‘uint16_t AESLib::decrypt64(char*, uint16_t, char*, unsigned char*, int, unsigned char*)’:

C:\Users\af\Documents\Arduino\libraries\AESLib\src\AESLib.cpp:222:50: error: ‘memset_s’ was not declared in this scope

int er = memset_s( out, sizeof(out), 0, b64len );


exit status 1
Error compiling for board WeMos D1 R1.

This report would have more information with
“Show verbose output during compilation”
option enabled in File -> Preferences.

How can I fix this error? Thanks.

This forum is about PlatformIO, an alternative to the Arduino IDE. It can build Arduino software but it is an IDE of its own. As such it does not cover the Arduino IDE.

This question might be more suitable in an Arduino forum. Or it would fit here if you switched to PlatformIO to build your software.


Not related to PIO, but anyways… The error you’re talking about was fixed in the main repository 8 days ago.

Just redownload the library from the master branch (here), remove the old one in your Arduino libraries directory and install the new one.


I did download the latest version of the library. The example still does not compile. AESlib.cpp still calls memset_s. I have modified AESlib.cpp myself to call memset instead of memset_s and it works now. I believe memset_s is not defined in Arduino.

Right, but it also adds an include for #include <iostream> as a fix. This also says it’s defined in string.h. I would not replace memset_s with memset because they explicitly call the safe variant of memset in the crypto library (guaranteed to overwrite memory, forbidden to be optimized away by the compiler). For destroying key material or the decryption results, it’s pretty important that this is done properly.

This fix does not work. The example in the library still does not compile. “string.h” in Arduino does not define memset_s. I would suggest that you compile the examples before publishing in the platform.

Libraries are published by the author of the libraries, PlatformIO doesn’t register them themselves… Redirect the statement that the fix published in the library’s repo doesn’t work to Issues · suculent/thinx-aes-lib · GitHub.

1 Like

Either roll back to version 2.0.2 of the library (you can do so through Tools → Manage Libraries, searching for the AESLib and then choosing 2.0.2 as the version to install), and wait for it to be fixed, or point out to the author via the issues link Max gave above that with the latest 2.0.4 version of the library, the simple.ino example is NOT compiling on for either the Arduino Uno or the ESP8266 (latest board support package for each), which is funny because these are the boards it’s specifically supposed to have been tested against. I’ve opened an issue here pointing out several of the included examples don’t work - whether that’s due to the examples not having been updated or bugs in the library, I don’t know. The latest commits are in relation to API changes though, so it could be the examples are out of date.

Author pushed v2.0.5 which should now be working. So either update to 2.0.5 when it becomes visible to your library manager, or you can manually pull it from github now.

1 Like

Thanks for your support. I appreciate it.

1 Like