Problems with splitting program into multiple files

Hey there, I have a problem where I tried to split my code into two files, the main sketch file and a cpp file containing the utility functions.

I'm getting these errors during compile:

Arduino: 1.8.5 (Windows 7), Board: "Arduino/Genuino 101"

sketch\helper.cpp.o: In function `resetSteppers(AccelStepper, AccelStepper)':

sketch/helper.cpp:4: multiple definition of `resetSteppers(AccelStepper, AccelStepper)'

sketch\Robo_IRCamV2.ino.cpp.o:sketch/helper.cpp:4: first defined here

sketch\helper.cpp.o: In function `resetSteppers(AccelStepper, AccelStepper)':

sketch/helper.cpp:4: multiple definition of `stepMotors(AccelStepper, AccelStepper)'

sketch\Robo_IRCamV2.ino.cpp.o:C:\Users\Radek\Documents\Arduino\Robo_IRCamV2/Robo_IRCamV2.ino:27: first defined here

sketch\helper.cpp.o: In function `resetSteppers(AccelStepper, AccelStepper)':

sketch/helper.cpp:4: multiple definition of `traveledDistance(AccelStepper, AccelStepper)'

sketch\Robo_IRCamV2.ino.cpp.o:C:\Users\Radek\Documents\Arduino\Robo_IRCamV2/Robo_IRCamV2.ino:27: first defined here

sketch\helper.cpp.o: In function `resetSteppers(AccelStepper, AccelStepper)':

sketch/helper.cpp:4: multiple definition of `rotation(AccelStepper, AccelStepper)'

sketch\Robo_IRCamV2.ino.cpp.o:C:\Users\Radek\Documents\Arduino\Robo_IRCamV2/Robo_IRCamV2.ino:27: first defined here

collect2.exe: error: ld returned 1 exit status

Multiple libraries were found for "AccelStepper.h"
 Used: C:\Users\Radek\Documents\Arduino\libraries\AccelStepper
 Not used: C:\Users\Radek\Documents\Arduino\libraries\AccelStepper-master
Multiple libraries were found for "Servo.h"
 Used: C:\Users\Radek\AppData\Local\Arduino15\packages\Intel\hardware\arc32\1.0.7\libraries\Servo
 Not used: C:\Program Files (x86)\Arduino\libraries\Servo
exit status 1
Error compiling for board Arduino/Genuino 101.

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

And here are the files on pastebin:
Sketch: #include "config.h"#ifndef CONFIG#error "Config not imported!"#endif#i - Pastebin.com
helper.cpp: #include <AccelStepper.h>#include "config.h"void resetSteppers(AccelSteppe - Pastebin.com
config.h: #ifndef CONFIG #define CONFIG#endif// Debug#define DEBUG// IR Pro - Pastebin.com

The problem is caused by this line of your sketch:

#include "helper.cpp"

Generally the way this is done is to have a .h file with prototypes for all the functions defined in the .cpp file. Include that .h file from the .cpp file and the .ino file. It's very rare to see a .cpp file included and I think usually when you do see it that's because the person doesn't know what they're doing.

Your helper.cpp file is compiled, creating a resetSteppers() function.

Then, your sketch is compiled, after the contents of the helper.cpp file are copied into it, creating another resetSteppers() function.

The linker then links the sketch.o file and the helper.o file, and finds two copies of the resetSteppers() function.

As pert says, it is very unusual to include a cpp file. And, now you know why it is unusual, and what problems it causes.