Multple definition of funtion

Hello I am working wake up word detection with ESP32 and INMP441. I jus generate Arduino Library from and add as .zip file and meet this error

c:/users/huy/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Huy\AppData\Local\Temp\arduino-sketch-3EFD89D7DA6633C8A0CB58964F213C4D\libraries\thesis_inferencing\edge-impulse-sdk\porting\espressif\objs.a(debug_log.cpp.o): in function `DebugLog(char const*)':
c:\Users\Huy\Documents\Arduino\libraries\thesis_inferencing\src\edge-impulse-sdk\porting\espressif/debug_log.cpp:34: multiple definition of `DebugLog(char const*)'; C:\Users\Huy\AppData\Local\Temp\arduino-sketch-3EFD89D7DA6633C8A0CB58964F213C4D\libraries\thesis_inferencing\edge-impulse-sdk\porting\arduino\objs.a(debug_log.cpp.o):c:\Users\Huy\Documents\Arduino\libraries\thesis_inferencing\src\edge-impulse-sdk\porting\arduino/debug_log.cpp:34: first defined here
c:/users/huy/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Huy\AppData\Local\Temp\arduino-sketch-3EFD89D7DA6633C8A0CB58964F213C4D\libraries\thesis_inferencing\edge-impulse-sdk\porting\espressif\objs.a(ei_classifier_porting.cpp.o): in function `ei_read_timer_ms()':
c:\Users\Huy\Documents\Arduino\libraries\thesis_inferencing\src\edge-impulse-sdk\porting\espressif/ei_classifier_porting.cpp:47: multiple definition of `ei_read_timer_ms()'; C:\Users\Huy\AppData\Local\Temp\arduino-sketch-3EFD89D7DA6633C8A0CB58964F213C4D\libraries\thesis_inferencing\edge-impulse-sdk\porting\arduino\objs.a(ei_classifier_porting.cpp.o):c:\Users\Huy\Documents\Arduino\libraries\thesis_inferencing\src\edge-impulse-sdk\porting\arduino/ei_classifier_porting.cpp:41: first defined here
c:/users/huy/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Huy\AppData\Local\Temp\arduino-sketch-3EFD89D7DA6633C8A0CB58964F213C4D\libraries\thesis_inferencing\edge-impulse-sdk\porting\espressif\objs.a(ei_classifier_porting.cpp.o): in function `ei_read_timer_us()':
c:\Users\Huy\Documents\Arduino\libraries\thesis_inferencing\src\edge-impulse-sdk\porting\espressif/ei_classifier_porting.cpp:51: multiple definition of `ei_read_timer_us()'; C:\Users\Huy\AppData\Local\Temp\arduino-sketch-3EFD89D7DA6633C8A0CB58964F213C4D\libraries\thesis_inferencing\edge-impulse-sdk\porting\arduino\objs.a(ei_classifier_porting.cpp.o):c:\Users\Huy\Documents\Arduino\libraries\thesis_inferencing\src\edge-impulse-sdk\porting\arduino/ei_classifier_porting.cpp:45: first defined here
collect2.exe: error: ld returned 1 exit status

I use Arduino IDE version 2.0.0 and esp32 arduino-esp32 version 2.0.3.
I don’t know how to fix. Please help me.
Thanks in advance

Hi @HuyYuh,

We’ve recently released official support for ESP32 using ESP-IDF. I would suggest to use it instead of Arduino to get better performances.

If you still want to use Arduino, you’ll need to modify the exported library to bypass the multiple definitions error:

  • Open the Arduino libraries directory and navigate to your exported project (ie: Documents/Arduino/libraries/MyEIProject)
  • Modify the src/edge-impulse-sdk/porting/ei_classifier_porting.h file as follows:
#ifndef EI_PORTING_ESPRESSIF
#ifdef CONFIG_IDF_TARGET_ESP32
#define EI_PORTING_ESPRESSIF      0

^ initial value for EI_PORTING_ESPRESSIF is 1.

Aurelien

Hi @aurel ,
The ei_classifier_porting.h file is as same as what you told me how to config

@HuyYuh,

You need to set the EI_PORTING_ESPRESSIF to 0 in the #define section.

Aurelien

1 Like