Undefined reference?

I'm copying this code and I go to verify, but I get a bunch of
undefined reference errors.

The code:

#include <ServoEasing.h>
ServoEasing servoTop;
ServoEasing servoBottom;
const int action_pin = 2;
int location = 31;
// Below numbers should be adjusted in case the facemask does not close/open to desired angle
int bottom_closed = 107;
int top_closed = 167;
int bottom_open = 20;
int top_open = 20;
void setup()
{
pinMode(action_pin, INPUT_PULLUP);
servoTop.attach(9);
servoBottom.attach(10);
setSpeedForAllServos(190);
servoTop.setEasingType(EASE_CUBIC_IN_OUT);
servoBottom.setEasingType(EASE_CUBIC_IN_OUT);
synchronizeAllServosStartAndWaitForAllServosToStop();
}
void loop()
{
int proximity = digitalRead(action_pin);
if (proximity == LOW)
{
if (location > bottom_open) {
servoTop.setEaseTo(top_open);
servoBottom.setEaseTo(bottom_open);
synchronizeAllServosStartAndWaitForAllServosToStop();
location = bottom_open;
delay(600);
} else {
servoTop.setEaseTo(top_closed);
servoBottom.setEaseTo(bottom_closed);
synchronizeAllServosStartAndWaitForAllServosToStop();
location = bottom_closed;
delay(600);
}
}
}

The error:

This is using the arduino IDE 2.1.2.

I've tried

#include "ServoEasing.h"

and I've tried

#include <ServoEasing.h>

Thoughts?

Please insert the error messages as text.

According to the documentation, that should be:

#include <ServoEasing.hpp>

On iOS you can copy and paste text from images


function 'setup': \Documents \Arduino\sketch_aug23a/sketch_aug23a. ino:14: undefined reference to ServoEasing::attach (int)'
\Documents \Arduino\sketch aug23a/sketch aug23a.ino:15: undefined reference to 'ServoEasing:: attach(int)'
\Documents \Arduino\sketch_aug23a/sketch_aug23a.ino:16: undefined reference to setSpeedForAlIServos (unsigned int)'
\Documents \Arduino\sketch aug23a/sketch aug23a.ino:17: undefined reference to 'ServoEasing:: setEasingType(unsigned char)'
\Documents\Arduino\sketch_aug23a/sketch_aug23a.ino:18: undefined reference to
"ServoEasing::setEasingType(unsigned char)'
\Documents \Arduino\sketch aug23a/sketch aug23a.ino:19: undefined reference to 'synchronizeAlIServosStartAndWaitForAlIServosToStop()'
\AppData\Local\Temp\ccnD5BHO.Itrans@.Itrans.o: In function "loop':
\Documents\Arduino\sketch aug23a/sketch aug23a.ino:27: undefined reference to
'ServoEasing::setEaseTo(int)'
\Documents \Arduino\sketch_aug23a/sketch_aug23a. ino:28: undefined reference to ServoEasing: :setEaseTo (int)'
\Documents \Arduino\sketch aug23a/sketch aug23a.ino:29: undefined reference to 'synchronizeAlIServosStartAndWaitForAlIServosToStop()' \Documents\Arduino\sketch_aug23a/sketch_aug23a.ino:33: undefined reference to 'ServoEasing::setEaseTo(int)'
\Documents \Arduino\sketch aug23a/sketch aug23a.ino:34: undefined reference to 'ServoEasing:: setEaseTo(int)'
\Documents \Arduino\sketch_aug23a/sketch_aug23a. ino:35: undefined reference to 'synchronizeAllServosStartAndwaitForAliServosTostop()
\AppData\Local\Temp\ccnD5BHO.Itranse.Itrans.o: In function ' _GLOBAL sub I servoTop':
(Documents\Arduino\sketch_aug23a/sketch_aug23a.ino:2: undefined reference to 'ServoEasing: :ServoEasing()'
\Documents\Arduino\sketch aug23a/sketch_ aug23a.ino:3: undefined reference to
"ServoEasing::ServoEasing()

So seems ServoEasing library or class is unknown

@traderjoe
In all examples of this library the inclusion appears like this:

#include "ServoEasing.hpp"
and not like this :
#include <ServoEasing.h>.

I tested it in the simulator like this:
#include "ServoEasing.hpp"
and like this:
#include <ServoEasing.hpp>,
and it compiled in both cases.

When given .H and .HPP, does one default to .HPP?

It depends on how the project is structured.

In this case, it seems that the author(s) put the implementation in .hpp files (which include the corresponding .h files), which are not compiled when not included. Hence the "undefined reference" linker errors when the .h file is included only.

When the .hpp files are renamed to .cpp files and the appropriate include (Arduino.h) is added, the example compiles when the .h file is used.

See the diff for details.
diff --git a/src/LightweightServo.hpp b/src/LightweightServo.cpp
similarity index 100%
rename from src/LightweightServo.hpp
rename to src/LightweightServo.cpp
diff --git a/src/LightweightServo.h b/src/LightweightServo.h
index 34dbe6c..4eaf3cd 100644
--- a/src/LightweightServo.h
+++ b/src/LightweightServo.h
@@ -1,3 +1,4 @@
+#include <Arduino.h>
 /*
  * LightweightServo.h
  *
diff --git a/src/ServoEasing.hpp b/src/ServoEasing.cpp
similarity index 100%
rename from src/ServoEasing.hpp
rename to src/ServoEasing.cpp
diff --git a/src/ServoEasing.h b/src/ServoEasing.h
index 0085a65..92c7f2c 100644
--- a/src/ServoEasing.h
+++ b/src/ServoEasing.h
@@ -882,8 +882,4 @@ bool checkI2CConnection(uint8_t aI2CAddress, Stream *aSerial); // Print class ha
  * - added convenience function clipDegreeSpecial().
  */
 
-#if !defined(_SERVO_EASING_HPP) && !defined(SUPPRESS_HPP_WARNING)
-#warning You probably must change the line #include "ServoEasing.h" to #include "ServoEasing.hpp" in your ino file or define SUPPRESS_HPP_WARNING before the include to suppress this warning.
-#endif
-
 #endif // _SERVO_EASING_H

Thank you.