I'm trying to use the FastNoise library with a Due, however, I get something like the following errors, when I try to complie.

error: 'abs' was not declared in this scope
error: 'mt19937' is not a member of 'std'
error: 'uniform_int_distribution' is not a member of 'std'

so I added the following:

#include <cstdlib>
#include <cmath>
#include <random>

which solved most of the problems, however it still says printf hasn't been declared. So I tried to edit cstdio to comment out the #undef printf, but it just brought back the full list of error messages, so that's not the solution. I googled some solutions but none of these seem to work. Do you have any suggestions I should try?

I'm not trying to use printf, just want to use the library.

Thanks for any help.

  • Also asked here: forum.arduino.cc/index.php?topic=579997.0 and we still don't know which library you are trying to port to the arduino. – Jot Nov 18 '18 at 18:20
  • apologies for spamming, this one: github.com/Auburns/FastNoise – Gergo Nov 18 '18 at 21:30
  • I don't know how the std and algorithm extensions are used in the gcc compiler for arduino. They are not used a lot. I think it should be possible to convert it to normal c++ code. The printf might be connected with the std and the cstdlib extension. The arduino preprocessor includes most common include files, only extra libraries needs to be included. Your title of this question is about FastNoise, but the problem is how to port code to the arduino. Perhaps you can change the title of the question to get attention from experts. – Jot Nov 19 '18 at 21:14

The FastNoise library compiles as it is for the Arduino MKR and Arduino Zero, but there is a "not cool" issue for the Due: https://github.com/arduino/ArduinoCore-samd/issues/308

A issue with assert can easily be solved, but the #include <algorithm> and #include <random> are somehow linked to a printf function.
I thought it was very hard, but then @Juraj wrote in his answer about the simple solution to comment out the #undef printf line.

In the file cstdio is a list of about fourty #undef lines. Only the printf requires to be commented out.

// #undef printf

The file is located in the hidden "Arduino15" folder in the build environment for the Due: Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\c++\4.8.3\cstdio

Then it will also compile for the Arduino Due (even without removing the assert). There are many warnings.

I was able to run it on a SAMD21 processor and it produces random numbers. However, I am not sure that those numbers are correct. I don't know if the many compiler warnings can be ignored.

#include <FastNoise.h>

FastNoise myNoise; // Create a FastNoise object

float heightMap[32][32]; // 2D heightmap to create terrain

void setup() {

  myNoise.SetNoiseType(FastNoise::SimplexFractal); // Set the desired noise type

  for(int x=0; x<32; x++) {
    for(int y=0; y<32; y++) {
      heightMap[x][y] = myNoise.GetNoise(x,y);

void loop() {

Do you know the XY Problem? You did not explain the reason for trying to make that library run on a Arduino Due. Perhaps there is an other way for what you want to achieve.

The Arduino Due was a major update for the Arduino boards, but nowadays some say to avoid the Arduino Due because it has issues (hardware and software).

I have updated my answer with help of the answer from @Juray.

  • Thank you guys, I tried to remove that line before, but it just say the same error messages when no library was included (it misses the abs function and so on). Moreover, I was unable to compile it for Zero or MKR. Is it possible that something is missing for me? I have the regular Arduino IDE and downloaded the latest boards. (the error message is around 1000 lines, maybe these are the warnings you mention? however for me it does not compile) – Gergo Nov 25 '18 at 22:50
  • I'm experimenting with LEDs with the FastLED library and serial communication, but the communication wasn't perfect since these LEDs (WS2812B) require precise timing, and the interrupts are disabled while the Uno is sending the LED data. So on the FastLED help page advises to switch to Teensy or Due. Since Due seemed the easier step from the Uno, I chose that. And with the added computational capacity I thought I can use the FastNoise library for noise generation instead of the FastLED one (which is fine, but has its faults). So I'm not persisting on using Due at all. – Gergo Nov 25 '18 at 23:06
  • Do you think the FastNoise could be run on Teensy? Or that would be even harder to make work? Teensy seems way more powerful on floating point math (which this library uses) than Zero. Unfortunately I'm not even sure how much processing power I need exactly, I was just about to check how fast the Due is with the library (since I had to switch anyway because of the serial communication issue with the Uno).. – Gergo Nov 25 '18 at 23:12
  • @Gergo, you might try to get the FastNoise library files again, maybe something has been changed. It compiles for the zero and mkr and by commenting out that line also for the due. I have no experience with the teensy. Stackexchange is about questions and answers. You could update your question that you want to use it for ws2812b leds and that the teensy or due is advised, and so on. – Jot Nov 26 '18 at 17:19
  • FastNoise did not change in the last year or so according to github, so I was skeptical about downloading it again, but did it nevertheless, and now it complies. I'm not sure what went wrong, since I should have the same FastNoise, as it did not change seemingly. Anyways, thank you very much for your time and help in this matter. Additionally thank you for the guidance how to use this forum. – Gergo Dec 3 '18 at 12:59

The workaround is in the issue found by Jot. In file


comment the line

#undef printf

and it will compile

  • Thanks, I missed that. I have updated my answer. – Jot Nov 22 '18 at 13:39
  • @Jot, the line must be removed – Juraj Nov 22 '18 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.