Error ReceiveOnlySoftwareSerial in fuction read() multiple definitions

Hello,
I'm new to arduino and I'm following a step by step on setting up a bill aceptor with arduino and I'm getting this error and I have google it but havent got the correct answear. Could anyone help me please.

Arduino: 1.6.12 (Windows 10), Board: "Arduino/Genuino Uno"

libraries\ReceiveOnlySoftwareSerial\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin): In function `ReceiveOnlySoftwareSerial::read()':

(.text+0x0): multiple definition of `ReceiveOnlySoftwareSerial::read()'

sketch\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\ReceiveOnlySoftwareSerial\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin): In function `ReceiveOnlySoftwareSerial::read()':

(.text+0x0): multiple definition of `ReceiveOnlySoftwareSerial::active_object'

sketch\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\ReceiveOnlySoftwareSerial\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin): In function `ReceiveOnlySoftwareSerial::read()':

(.text+0x0): multiple definition of `ReceiveOnlySoftwareSerial::_receive_buffer_head'

sketch\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\ReceiveOnlySoftwareSerial\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin): In function `ReceiveOnlySoftwareSerial::read()':

(.text+0x0): multiple definition of `ReceiveOnlySoftwareSerial::_receive_buffer_tail'

sketch\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\ReceiveOnlySoftwareSerial\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin): In function `ReceiveOnlySoftwareSerial::read()':

(.text+0x0): multiple definition of `ReceiveOnlySoftwareSerial::_receive_buffer'

sketch\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\ReceiveOnlySoftwareSerial\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin): In function `ReceiveOnlySoftwareSerial::read()':

(.text+0x0): multiple definition of `ReceiveOnlySoftwareSerial::write(unsigned char)'

sketch\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\ReceiveOnlySoftwareSerial\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin): In function `ReceiveOnlySoftwareSerial::read()':

(.text+0x0): multiple definition of `ReceiveOnlySoftwareSerial::peek()'

sketch\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\ReceiveOnlySoftwareSerial\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin): In function `ReceiveOnlySoftwareSerial::read()':

(.text+0x0): multiple definition of `ReceiveOnlySoftwareSerial::available()'

sketch\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\ReceiveOnlySoftwareSerial\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin): In function `ReceiveOnlySoftwareSerial::read()':

(.text+0x0): multiple definition of `ReceiveOnlySoftwareSerial::flush()'

sketch\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\ReceiveOnlySoftwareSerial\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin): In function `ReceiveOnlySoftwareSerial::read()':

(.text+0x0): multiple definition of `ReceiveOnlySoftwareSerial::recv()'

sketch\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\ReceiveOnlySoftwareSerial\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin): In function `ReceiveOnlySoftwareSerial::read()':

(.text+0x0): multiple definition of `ReceiveOnlySoftwareSerial::listen()'

sketch\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\ReceiveOnlySoftwareSerial\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin): In function `ReceiveOnlySoftwareSerial::read()':

(.text+0x0): multiple definition of `ReceiveOnlySoftwareSerial::rx_pin_read()'

sketch\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\ReceiveOnlySoftwareSerial\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin): In function `ReceiveOnlySoftwareSerial::read()':

(.text+0x0): multiple definition of `__vector_3'

sketch\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\ReceiveOnlySoftwareSerial\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin): In function `ReceiveOnlySoftwareSerial::read()':

(.text+0x0): multiple definition of `__vector_4'

sketch\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\ReceiveOnlySoftwareSerial\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin): In function `ReceiveOnlySoftwareSerial::read()':

(.text+0x0): multiple definition of `__vector_5'

sketch\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\ReceiveOnlySoftwareSerial\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin): In function `ReceiveOnlySoftwareSerial::read()':

(.text+0x0): multiple definition of `ReceiveOnlySoftwareSerial::setRX(unsigned char)'

sketch\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\ReceiveOnlySoftwareSerial\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin): In function `ReceiveOnlySoftwareSerial::read()':

(.text+0x0): multiple definition of `ReceiveOnlySoftwareSerial::ReceiveOnlySoftwareSerial(unsigned char, bool)'

sketch\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\ReceiveOnlySoftwareSerial\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin): In function `ReceiveOnlySoftwareSerial::read()':

(.text+0x0): multiple definition of `ReceiveOnlySoftwareSerial::ReceiveOnlySoftwareSerial(unsigned char, bool)'

sketch\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\ReceiveOnlySoftwareSerial\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin): In function `ReceiveOnlySoftwareSerial::read()':

(.text+0x0): multiple definition of `ReceiveOnlySoftwareSerial::begin(long)'

sketch\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\ReceiveOnlySoftwareSerial\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin): In function `ReceiveOnlySoftwareSerial::read()':

(.text+0x0): multiple definition of `ReceiveOnlySoftwareSerial::end()'

sketch\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\ReceiveOnlySoftwareSerial\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin): In function `ReceiveOnlySoftwareSerial::read()':

(.text+0x0): multiple definition of `ReceiveOnlySoftwareSerial::~ReceiveOnlySoftwareSerial()'

sketch\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\ReceiveOnlySoftwareSerial\ReceiveOnlySoftwareSerial.cpp.o (symbol from plugin): In function `ReceiveOnlySoftwareSerial::read()':

(.text+0x0): multiple definition of `ReceiveOnlySoftwareSerial::~ReceiveOnlySoftwareSerial()'

sketch\ReceiveOnlySoftwareSerial.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/Genuino Uno.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

If you show your code, we will be able to help; please embed it in code tags.

[code]
your code here
[/code]

And please post a link to the library that you use.

Hello,
in attachments you can find files which I try to compile. Also, there is error message (from Arduino IDE) in .txt file.
Please, if someone can help, and tell me where I make mistake.
THANK YOU IN ADVANCE!!!

error_messages.txt (13.9 KB)

ARDUINO_MEGA_MASTER_v6_1.ino (7.03 KB)

cycleRunState.cpp (5.31 KB)

cycleRunState.h (1.82 KB)

enabledState.cpp (1.48 KB)

enabledState.h (82 Bytes)

initializationState.cpp (2.05 KB)

initializationState.h (104 Bytes)

serviceState.cpp (14.3 KB)

serviceState.h (2.4 KB)

startEmergencyState.cpp (694 Bytes)

startEmergencyState.h (85 Bytes)

stopState.cpp (1.57 KB)

stopState.h (270 Bytes)

In attached file, you can find “extended” error log file.
THANK YOU!

error_messages_extened.txt (44.7 KB)

SOLVED!

In C++ (as well as in C) there is a difference between declaring and defining things like variables.
What I doing in the header file is defining the variables, which means that every source file that includes the header file will have the definitions.

In the header file should only declare the variables, and then in a single source file define them.

THANKS TO EVERYBODY!!!

In setup() you start diddling with timer registers, etc. without having disabled interrupts. Not a good thing to do.

You have included serviceState.h in the sketch, in serviceState.cpp, and in stopState.cpp. In serviceState.h, you have:

bool EXIT_SERVICE_STATE = false;

So, a variable named EXIT_SERVICE_STATE is created in the sketch.o file, in serviceState.o, and in stopState.o. When the linker looks at the three .o files, it sees that the same variable is defined in three places, so it complains.

You need to have ONE file that defines the variables, usually the sketch, and have extern statements everywhere else that the variable is needed (which can include being in a header file that is included in multiple places).