Redefinition/Previous Definition Error

Hey! I'm messing around with an ElechouseV3 Voice Recognition shield. I'm using one of the example coded included with the library, vr_sample_train, and keep getting this error message:

C:\arduino-1.8.5-windows\arduino-1.8.5\arduino-builder -dump-prefs -logger=machine -hardware C:\arduino-1.8.5-windows\arduino-1.8.5\hardware -tools C:\arduino-1.8.5-windows\arduino-1.8.5\tools-builder -tools C:\arduino-1.8.5-windows\arduino-1.8.5\hardware\tools\avr -built-in-libraries C:\arduino-1.8.5-windows\arduino-1.8.5\libraries -libraries C:\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10805 -build-path C:\Users\macke\AppData\Local\Temp\arduino_build_195865 -warnings=none -build-cache C:\Users\macke\AppData\Local\Temp\arduino_cache_597395 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\arduino-1.8.5-windows\arduino-1.8.5\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\arduino-1.8.5-windows\arduino-1.8.5\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\arduino-1.8.5-windows\arduino-1.8.5\hardware\tools\avr -verbose C:\Arduino\vr_sample_train\vr_sample_train\vr_sample_train.ino
C:\arduino-1.8.5-windows\arduino-1.8.5\arduino-builder -compile -logger=machine -hardware C:\arduino-1.8.5-windows\arduino-1.8.5\hardware -tools C:\arduino-1.8.5-windows\arduino-1.8.5\tools-builder -tools C:\arduino-1.8.5-windows\arduino-1.8.5\hardware\tools\avr -built-in-libraries C:\arduino-1.8.5-windows\arduino-1.8.5\libraries -libraries C:\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10805 -build-path C:\Users\macke\AppData\Local\Temp\arduino_build_195865 -warnings=none -build-cache C:\Users\macke\AppData\Local\Temp\arduino_cache_597395 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\arduino-1.8.5-windows\arduino-1.8.5\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\arduino-1.8.5-windows\arduino-1.8.5\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\arduino-1.8.5-windows\arduino-1.8.5\hardware\tools\avr -verbose C:\Arduino\vr_sample_train\vr_sample_train\vr_sample_train.ino
Using board 'uno' from platform in folder: C:\arduino-1.8.5-windows\arduino-1.8.5\hardware\arduino\avr
Using core 'arduino' from platform in folder: C:\arduino-1.8.5-windows\arduino-1.8.5\hardware\arduino\avr
Detecting libraries used...
"C:\arduino-1.8.5-windows\arduino-1.8.5\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\arduino-1.8.5-windows\arduino-1.8.5\hardware\arduino\avr\cores\arduino" "-IC:\arduino-1.8.5-windows\arduino-1.8.5\hardware\arduino\avr\variants\standard" "C:\Users\macke\AppData\Local\Temp\arduino_build_195865\sketch\vr_sample_train.ino.cpp" -o "nul"
"C:\arduino-1.8.5-windows\arduino-1.8.5\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\arduino-1.8.5-windows\arduino-1.8.5\hardware\arduino\avr\cores\arduino" "-IC:\arduino-1.8.5-windows\arduino-1.8.5\hardware\arduino\avr\variants\standard" "-IC:\Arduino\libraries\VoiceRecognitionV3" "C:\Users\macke\AppData\Local\Temp\arduino_build_195865\sketch\vr_sample_train.ino.cpp" -o "nul"
"C:\arduino-1.8.5-windows\arduino-1.8.5\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\arduino-1.8.5-windows\arduino-1.8.5\hardware\arduino\avr\cores\arduino" "-IC:\arduino-1.8.5-windows\arduino-1.8.5\hardware\arduino\avr\variants\standard" "-IC:\Arduino\libraries\VoiceRecognitionV3" "-IC:\arduino-1.8.5-windows\arduino-1.8.5\hardware\arduino\avr\libraries\SoftwareSerial\src" "C:\Users\macke\AppData\Local\Temp\arduino_build_195865\sketch\vr_sample_train.ino.cpp" -o "nul"
"C:\arduino-1.8.5-windows\arduino-1.8.5\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\arduino-1.8.5-windows\arduino-1.8.5\hardware\arduino\avr\cores\arduino" "-IC:\arduino-1.8.5-windows\arduino-1.8.5\hardware\arduino\avr\variants\standard" "-IC:\Arduino\libraries\VoiceRecognitionV3" "-IC:\arduino-1.8.5-windows\arduino-1.8.5\hardware\arduino\avr\libraries\SoftwareSerial\src" "C:\Arduino\libraries\VoiceRecognitionV3\VoiceRecognitionV3.cpp" -o "nul"
"C:\arduino-1.8.5-windows\arduino-1.8.5\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\arduino-1.8.5-windows\arduino-1.8.5\hardware\arduino\avr\cores\arduino" "-IC:\arduino-1.8.5-windows\arduino-1.8.5\hardware\arduino\avr\variants\standard" "-IC:\Arduino\libraries\VoiceRecognitionV3" "-IC:\arduino-1.8.5-windows\arduino-1.8.5\hardware\arduino\avr\libraries\SoftwareSerial\src" "C:\arduino-1.8.5-windows\arduino-1.8.5\hardware\arduino\avr\libraries\SoftwareSerial\src\SoftwareSerial.cpp" -o "nul"
Generating function prototypes...
"C:\arduino-1.8.5-windows\arduino-1.8.5\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\arduino-1.8.5-windows\arduino-1.8.5\hardware\arduino\avr\cores\arduino" "-IC:\arduino-1.8.5-windows\arduino-1.8.5\hardware\arduino\avr\variants\standard" "-IC:\Arduino\libraries\VoiceRecognitionV3" "-IC:\arduino-1.8.5-windows\arduino-1.8.5\hardware\arduino\avr\libraries\SoftwareSerial\src" "C:\Users\macke\AppData\Local\Temp\arduino_build_195865\sketch\vr_sample_train.ino.cpp" -o "C:\Users\macke\AppData\Local\Temp\arduino_build_195865\preproc\ctags_target_for_gcc_minus_e.cpp"
"C:\arduino-1.8.5-windows\arduino-1.8.5\tools-builder\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\macke\AppData\Local\Temp\arduino_build_195865\preproc\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\arduino-1.8.5-windows\arduino-1.8.5\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\arduino-1.8.5-windows\arduino-1.8.5\hardware\arduino\avr\cores\arduino" "-IC:\arduino-1.8.5-windows\arduino-1.8.5\hardware\arduino\avr\variants\standard" "-IC:\Arduino\libraries\VoiceRecognitionV3" "-IC:\arduino-1.8.5-windows\arduino-1.8.5\hardware\arduino\avr\libraries\SoftwareSerial\src" "C:\Users\macke\AppData\Local\Temp\arduino_build_195865\sketch\vr_sample_train.ino.cpp" -o "C:\Users\macke\AppData\Local\Temp\arduino_build_195865\sketch\vr_sample_train.ino.cpp.o"
In file included from C:\Arduino\vr_sample_train\vr_sample_train\vr_sample_train.ino:31:0:

C:\Arduino\libraries\VoiceRecognitionV3/VoiceRecognitionV3.h:106:7: error: redefinition of 'class VR'

 class VR : public SoftwareSerial{

       ^

In file included from C:\Arduino\vr_sample_train\vr_sample_train\vr_sample_train.ino:1:0:

C:\Arduino\libraries\VoiceRecognitionV3/VoiceRecognitionV3.h:106:7: error: previous definition of 'class VR'

 class VR : public SoftwareSerial{

       ^

Using library VoiceRecognitionV3 in folder: C:\Arduino\libraries\VoiceRecognitionV3 (legacy)
Using library SoftwareSerial at version 1.0 in folder: C:\arduino-1.8.5-windows\arduino-1.8.5\hardware\arduino\avr\libraries\SoftwareSerial 
exit status 1
Error compiling for board Arduino/Genuino Uno.

I haven't changed anything in the sample code, so I'm not sure what the problem is.

Also, I'm kind of new to this stuff and not the most technologically inclined, so please dumb your answers down for me. :slight_smile:

Post a link to where you got the library from. Please use the chain links icon on the toolbar to make it clickable.

https://www.elechouse.com/elechouse/index.php?main_page=product_info&cPath=168_170&products_id=2254&zenid=b5faid0nr1fo3e9or2g8qpc721

With links to manual and how-to videos.

It looks like you have accidentally added an additional #include directive for VoiceRecognitionV3.h to the vr_sample_train sketch at line 1. Something like this:

#include <VoiceRecognitionV3.h>

If you delete that line the problem will be solved.

Likely what happened is you thought you needed to do Sketch > Include Library > VoiceRecognitionV3, which adds that line but that is only necessary if your are writing a sketch from scratch. The supplied example sketches already contain that line. Ordinarily having duplicate #include directives would be no problem because it's best practices to add some simple code to deal with that occurrence but the author of the library failed to follow these best practices.

After some investigation I found that the library link you posted:

macki34549:
Voice-Recognition-with-Elechouse-V3/VoiceRecognitionV3.zip at master · kksjunior/Voice-Recognition-with-Elechouse-V3 · GitHub

is not the official repository for the library. The official one is here:

I have submitted a pull request to add the include guard:

which will prevent others from encountering the same problem you had.

Thank you so much!!

I was having many errors of "Redefinition of..." many things and was because I created a copy of the file in the same directory to backup it. So if you want to backup the .ino file do it to another directory. I know it sounds a silly error, I am new here, but if I did it, somebody else could do it too.
Maybe there is a better way to backup some point of our sketch

If you have a second .ino file in the same folder as your original then it will appear as a second tab in the IDE and will be compiled into the main program.

paborralho:
I was having many errors of "Redefinition of..." many things and was because I created a copy of the file in the same directory to backup it. So if you want to backup the .ino file do it to another directory. I know it sounds a silly error, I am new here, but if I did it, somebody else could do it too.
Maybe there is a better way to backup some point of our sketch

"Save As" the whole project under a new name. If the name always ends with a revision number like flibbert001, flibbert002 then the folders will appear together in your Sketchbook as a set of folders. It's not great but it works to keep work on the same project together.

paborralho:
Maybe there is a better way to backup some point of our sketch

By far, the most common, professional way to do this is using some software named Git. It's a fairly complex program, so probably not worth using if you're just getting started learning about Arduino, but as soon as you start into some more advanced programs it is so worth the effort. So even if it's not right for you currently, keep it in mind.

You can use Git right from the command line if that's your thing, but there are also a lot of Git client software options that provide a friendly GUI. A very beginner friendly one is GitHub Desktop:

Although this has GitHub integration, it is not necessary to put your programs on GitHub if you don't want.

A more advanced option, and my favorite, is Git Extensions: