Error when compiling: multiple definition

Hi,
this is not a problem with PlatformIO, but with my programming skills.
I am trying to program an automated distiller. For that I use this library.

My problem arises when I try split the program code in multiple files.
Here the link to my Repo, the error message is multiple definition of `fsm’ in following files:
states\start.cpp, states\proc_start.cpp, states\end.cpp and main.cpp

It’s a Arduino Project on a ESP32.
Can someone help me please? Best with a pull request.

Is there anything I can improve on this project? Lint rules or something similar.

Thanks.

Strong no.

You want to share a global variable (fsm) accross multiple files, but you’re doing it wrongly and end up defining (=creating) that global variable in every single file that does a #include "main.h". Only one file can create a global variable under a certain name, the others need to just get the declaration.

This has been discussed multiple times in Multiple definitions of... error | first defined here... Build Failure.

The solution is to use to

extern SimpleFSM fsm;

in the main.h file and the addition of

SimpleFSM fsm;

in main.cpp after all headers are included.

thanks now it works.