Multiple definitions of "xxxx" I really need your help. I use VisualStudio and PlatformIo I still get this error: 


  Linking .pioenvs\esp12e\firmware.elf
  .pioenvs\esp12e\src\main.cpp.o:(.data.DebugX+0x0): multiple definition of `DebugX'
  .pioenvs\esp12e\src\customFunctions.cpp.o:(.data.DebugX+0x0): first defined here
  collect2.exe: error: ld returned 1 exit status
  *** [.pioenvs\esp12e\firmware.elf] Error 1


I use header guards in my file, so I do not understand why is this part of code redeclared. I had to miss some elementary in cpp programming but I still can't get it to work.

Copy of my project: 
https://bitbucket.org/fires/programingtesting/src/master/ESP8266/cpp/RedefinedError/

main.cpp

    #include &lt;Arduino.h&gt;;
    #include "../include/defines.h"
    //#include "../include/customFunctions.h"
    // Time
    uint32_t mTimeToSec = 0;
    uint32_t mTimeSeconds = 0;
    void setup() {
    etc. etc. etc.


customFunction.h

    #pragma once
    #ifndef CUSTOMFUNCTIONS_H
    #define CUSTOMFUNCTIONS_H
    void connectWiFi();
    void initializeOTA();
    #endif


defines.h

    #pragma once
    #ifndef DEFINES_H
    #define DEFINES_H
    #include &lt;jled.h&gt;
    #define BowlingLed 5
    #define StatekLed 4
    int DebugX = 1;
    #endif


Thanks for the help, I read many articles and many issues but I still do not understand why DebugX is redefined if it is in header guard.
Included files are included before compilation, really replacing the #include with the content of the file.

If you write int DebugX = 1; you define a variable. And it is defined in every source file which includes it. Then the linker finds it in more then one unit and ends with "multiple definitions" error.

The variable must be defined only in one compilation unit (.c, .cpp). For example in your case customFunctions.cpp. To make it available in other source files put extern int DebugX; into the .h file.