Short question:
Do you have any idea what can be causing multiple definition error when trying to declare int bars;
in a global scope?
Detailed explanation:
Code in main.cpp
looks like this:
#include <Arduino.h>
int bars, bar, bars2;
void setup() {}
void loop() {}
Platformio settings in platformio.ini
:
[env]
framework = arduino
[env:main]
platform = espressif32
board = esp32doit-devkit-v1
And when I try to build I get following multiple definition error:
/home/vovo/.platformio/packages/toolchain-xtensa-esp32/bin/…/lib/gcc/xtensa-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld: /home/vovo/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/lib/libpp.a(pp.o):(.dram1.4+0x0): multiple definition of `bars’; .pio/build/main/src/main.cpp.o:/…/src/main.cpp:2: first defined here
collect2: error: ld returned 1 exit status
*** [.pio/build/main/firmware.elf] Error 1
There is no problem with bar
or bars2
but the compiler does not like the definition of bars
for some reason.
When I change platform = atmelavr
and board = uno
in platformio.ini
, the project compiles without any error. So the problem is probably with espressif32
platform.
When I do not declare bars
then I get not declared in this scope error when I try to access this variable. So it is not an imported var or function. Definition within setup()
works well.
Same error appears on two different computers so it should not be related to some cached settings etc.
I know, I can use different names for my variable but I am pretty sure it worked for me a few months ago.
I tried to upgrade pio
but pio --version
returns PlatformIO Core, version 6.1.5
which should be the latest version.
There is probably something stuping I am doing wrong but I am not able to figure out what it is.
Thanks