Error compiling for board Arduino Leonardo

Hey guys,

i am absolutely new to this Arduino stuff so i bought myself an Arduino Leonardo.
I wanted to just rebuild what the Guy AMStudio did in his video.

So i just downloaded his Code but cant upload it on my board. Now i have no idea why. Is it the wrong board or does the code not fit to the board? I would be very greatful for any idea!

The error:
libraries\Joystick\Joystick.cpp.o (symbol from plugin): In function Joystick_::Joystick_()': (.text+0x0): multiple definition of Joystick_::Joystick_()’
sketch\Joystick.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\Joystick\Joystick.cpp.o (symbol from plugin): In function Joystick_::Joystick_()': (.text+0x0): multiple definition of Joystick_::Joystick_()’
sketch\Joystick.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\Joystick\Joystick.cpp.o (symbol from plugin): In function Joystick_::Joystick_()': (.text+0x0): multiple definition of Joystick_::end()’
sketch\Joystick.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\Joystick\Joystick.cpp.o (symbol from plugin): In function Joystick_::Joystick_()': (.text+0x0): multiple definition of Joystick_::sendState()’
sketch\Joystick.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\Joystick\Joystick.cpp.o (symbol from plugin): In function Joystick_::Joystick_()': (.text+0x0): multiple definition of Joystick_::begin(bool)’
sketch\Joystick.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\Joystick\Joystick.cpp.o (symbol from plugin): In function Joystick_::Joystick_()': (.text+0x0): multiple definition of Joystick_::pressButton(unsigned char)’
sketch\Joystick.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\Joystick\Joystick.cpp.o (symbol from plugin): In function Joystick_::Joystick_()': (.text+0x0): multiple definition of Joystick_::releaseButton(unsigned char)’
sketch\Joystick.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\Joystick\Joystick.cpp.o (symbol from plugin): In function Joystick_::Joystick_()': (.text+0x0): multiple definition of Joystick_::setButton(unsigned char, unsigned char)’
sketch\Joystick.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\Joystick\Joystick.cpp.o (symbol from plugin): In function Joystick_::Joystick_()': (.text+0x0): multiple definition of Joystick_::setThrottle(unsigned char)’
sketch\Joystick.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\Joystick\Joystick.cpp.o (symbol from plugin): In function Joystick_::Joystick_()': (.text+0x0): multiple definition of Joystick_::setRudder(unsigned char)’
sketch\Joystick.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\Joystick\Joystick.cpp.o (symbol from plugin): In function Joystick_::Joystick_()': (.text+0x0): multiple definition of Joystick_::setXAxis(signed char)’
sketch\Joystick.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\Joystick\Joystick.cpp.o (symbol from plugin): In function Joystick_::Joystick_()': (.text+0x0): multiple definition of Joystick_::setYAxis(signed char)’
sketch\Joystick.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\Joystick\Joystick.cpp.o (symbol from plugin): In function Joystick_::Joystick_()': (.text+0x0): multiple definition of Joystick_::setZAxis(signed char)’
sketch\Joystick.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\Joystick\Joystick.cpp.o (symbol from plugin): In function Joystick_::Joystick_()': (.text+0x0): multiple definition of Joystick_::setXAxisRotation(int)’
sketch\Joystick.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\Joystick\Joystick.cpp.o (symbol from plugin): In function Joystick_::Joystick_()': (.text+0x0): multiple definition of Joystick_::setYAxisRotation(int)’
sketch\Joystick.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\Joystick\Joystick.cpp.o (symbol from plugin): In function Joystick_::Joystick_()': (.text+0x0): multiple definition of Joystick_::setZAxisRotation(int)’
sketch\Joystick.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\Joystick\Joystick.cpp.o (symbol from plugin): In function Joystick_::Joystick_()': (.text+0x0): multiple definition of Joystick_::setHatSwitch(signed char, int)’
sketch\Joystick.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\Joystick\Joystick.cpp.o (symbol from plugin): In function Joystick_::Joystick_()': (.text+0x0): multiple definition of Joystick’
sketch\Joystick.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Leonardo.

ANALOG_EBRAKE.ino (451 Bytes)

Joystick.cpp (6.94 KB)

Joystick.h (2.25 KB)

The problem is that you put the Joystick library in your sketch folder in addition to installing it as as a library as normal.

So you need to delete the files Joystick.cpp and Joystick.h from the sketch. You can do this from the Arduino IDE:

  • Click on the "Joystick.cpp" tab.
  • Click the downward pointing triangle button on the right side of the tab bar.
  • From the dropdown menu, click "Delete".
  • In the confirmation dialog, click "OK".

Now repeat that process with the "Joystick.h" tab.

Thank you very much :grinning:
it works.

Sketch uses 6112 bytes (21%) of program storage space. Maximum is 28672 bytes.
Global variables use 220 bytes (8%) of dynamic memory, leaving 2340 bytes for local variables. Maximum is 2560 bytes.

You're welcome. I'm glad to hear it's working now. Enjoy!
Per