Error compiling for board WEMOS LOLIN32

Compiling a simple sketch for WEMOS LOLIN32 board I get an error message that doesn’t seem to refer to anything in the code.

Sketch:

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define DISPLAY_RESET 4       // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3D   // 0x3D for 128x64, 0x3C for 128x32

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, DISPLAY_RESET);

void setup()
{
  Serial.begin(115200);
  Wire.begin(5, 4);       // I2C comms on ports SDA=5, SCL=4 on OLED

  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C, false, false)) // Address for 128x64
  {
    Serial.println(F("SSD1306 allocation failed"));
    for (;;);            // Don't proceed, loop forever
  }
  delay(2000);
  display.clearDisplay();

  static const uint8_t code_Array[8][16] =
  {
    {0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F},
    {0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F},
    {0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF},
    {0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF},
    {0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF},
    {0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF},
    {0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF},
    {0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xfE, 0xFF}
  };

  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0, 0);  
  for (uint8_t i = 0; i <= 8; i++)
  {
    for (uint8_t j = 0; j <= 16; j++)
    {
      display.print(code_Array[i][j]);      
    }
    display.display();
  }
}

Error message:

Arduino: 1.8.13 (Windows 10), Board: "WEMOS LOLIN32, 80MHz, Default, 240MHz (WiFi/BT), 921600"

C:\Users\hans\AppData\Local\Temp\arduino_cache_375079\core\core_600365080b52ab60b0924f16600e23b6.a(main.cpp.o):(.literal._Z8loopTaskPv+0x4): undefined reference to `loop()'
C:\Users\hans\AppData\Local\Temp\arduino_cache_375079\core\core_600365080b52ab60b0924f16600e23b6.a(main.cpp.o): In function `loopTask(void*)':
C:\Users\hans\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/main.cpp:17: undefined reference to `loop()'
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board WEMOS LOLIN32.

You have to put

void loop()
{
}

Even if it's empty

undefined reference to `loop()'

You didn't define the loop() function. If you don't need it, make it an empty function: void loop() {}

Pieter

guix:
You have to put

void loop()

{
}




Even if it's empty

Thank you. What an simple mistake.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.