I bought an ESP32 to try instead of an Arduino Mega. But I ran into a problem with my program. The program has the function of controlling the stepper motor through the LCD display and it runs without problems on Arduino Mega, but when I changed the board to ESP32 I had a problem with compilation. The biggest problem was with the libraries, which ESP probably doesn't support, but I somehow solved most of them, but I still can't solve this error. It has some problem with undefined reference to SPI. Does anyone know what to do with it? c:/users/kabic/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\kabic\AppData\Local\Temp\arduino\sketches\CDC8A33C5FCF4F11548CA88E6B41BEAB\sketch\ChickenGuard_V7_BETA_ESP32.ino.cpp.o:(.literal._Z5setupv+0x0): undefined reference to SPI' c:/users/kabic/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\kabic\AppData\Local\Temp\arduino\sketches\CDC8A33C5FCF4F11548CA88E6B41BEAB\sketch\ChickenGuard_V7_BETA_ESP32.ino.cpp.o:(.literal._Z5setupv+0xa0): undefined reference to SPIClass::begin(signed char, signed char, signed char, signed char)' c:/users/kabic/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\kabic\AppData\Local\Temp\arduino\sketches\CDC8A33C5FCF4F11548CA88E6B41BEAB\sketch\ChickenGuard_V7_BETA_ESP32.ino.cpp.o: in function SleepModeLogo()': C:\Users\kabic\Desktop\Projekt\Automatická kurníková dvířka\Programy\ChickenGuard_V7_BETA_ESP32/ChickenGuard_V7_BETA_ESP32.ino:372: undefined reference to `SPIClass::begin(signed char, signed char, signed char, signed char)' collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1`

  • 1
    \$\begingroup\$ Those kind of "I changed nothing besides the board and now it doesn't compile" problems often indicate that you need to update the libraries. Usually there's new versions available in the manager, so you don't even need to type anything to get it working again. Same with boards, make sure they are updated. \$\endgroup\$
    – dandavis
    Sep 28 at 22:20
  • 1
    \$\begingroup\$ If possible, make your question more readable by using relative paths instead of absolute. Right now a rough estimate of 2/5 of the question consists of paths. \$\endgroup\$
    – MiNiMe
    Sep 28 at 23:17
  • 1
    \$\begingroup\$ This is a linker error missing an instance of the SPI class. It may be as simple as adding a line #include "SPI.h" behind the line #include <Arduino.h>. \$\endgroup\$
    – Jens
    Sep 29 at 0:46
  • \$\begingroup\$ So the problem was that I updated SPI.h but forgot about SPI.cpp. But I ran into another problem and that is that it can't boot. This is shown on the serial monitor:15:04:16.536 -> rst:0x8 (TG1WDT_SYS_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT) 15:04:16.536 -> configsip: 0, SPIWP:0xee 15:04:16.536 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 15:04:16.536 -> mode:DIO, clock div:1 15:04:16.536 -> load:0x3fff0030,len:1344 15:04:16.536 -> load:0x40078000,len:13964 \$\endgroup\$
    – Kabl62
    Sep 29 at 13:22


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.