Error message - undefined reference

Hi

I am trying to compile this for an iron man helmet project using nano every.

I am hoping somebody can help as I am way out of my depth here, I was hoping it was going to be as easy as youtube promised it would be.

I installed the servoesing library which cleared the first problem but now I am getting undefined reference errors.

#include "ServoEasing.h"
ServoEasing servoTop;
ServoEasing servoBottom;
const int action_pin = 2;
const int ledPin = 6;
const int potPin = A0;
int location = 31;
int bottom_closed = 107;
int top_closed = 167;
int bottom_open = 20;
int top_open = 20;
int value;
int maxBrightness;
void setup() {
  pinMode(action_pin, INPUT_PULLUP);
  pinMode(potPin, INPUT);
  servoTop.attach(9);
  servoBottom.attach(10);
  setSpeedForAllServos(190);
  servoTop.setEasingType(EASE_CUBIC_IN_OUT);
  servoBottom.setEasingType(EASE_CUBIC_IN_OUT);
  synchronizeAllServosStartAndWaitForAllServosToStop();
}
void loop() {
  value = analogRead(potPin);
  maxBrightness = map(value, 250, 750, 0, 255);
  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(10);
      analogWrite(ledPin, 0);
    } else {
      servoTop.setEaseTo(top_closed);
      servoBottom.setEaseTo(bottom_closed);
      synchronizeAllServosStartAndWaitForAllServosToStop();
      location = bottom_closed;
      delay(50);
      analogWrite(ledPin, maxBrightness / 3);
      delay(100);
      analogWrite(ledPin, maxBrightness / 5);
      delay(100);
      analogWrite(ledPin, maxBrightness / 2);
      delay(100);
      analogWrite(ledPin, maxBrightness / 3);
      delay(100);
      analogWrite(ledPin, maxBrightness);
      delay(100);
    }
  }
}

error messages

C:\Users\stuar\AppData\Local\Temp\cclRWIGe.ltrans0.ltrans.o: In function setup': C:\Users\stuar\Desktop\sketch_mar14a/sketch_mar14a.ino:18: undefined reference to ServoEasing::attach(int)'
C:\Users\stuar\Desktop\sketch_mar14a/sketch_mar14a.ino:19: undefined reference to ServoEasing::attach(int)' C:\Users\stuar\Desktop\sketch_mar14a/sketch_mar14a.ino:20: undefined reference to setSpeedForAllServos(unsigned int)'
C:\Users\stuar\Desktop\sketch_mar14a/sketch_mar14a.ino:21: undefined reference to ServoEasing::setEasingType(unsigned char)' C:\Users\stuar\Desktop\sketch_mar14a/sketch_mar14a.ino:22: undefined reference to ServoEasing::setEasingType(unsigned char)'
C:\Users\stuar\Desktop\sketch_mar14a/sketch_mar14a.ino:23: undefined reference to synchronizeAllServosStartAndWaitForAllServosToStop()' C:\Users\stuar\AppData\Local\Temp\cclRWIGe.ltrans0.ltrans.o: In function loop':
C:\Users\stuar\Desktop\sketch_mar14a/sketch_mar14a.ino:33: undefined reference to ServoEasing::setEaseTo(int)' C:\Users\stuar\Desktop\sketch_mar14a/sketch_mar14a.ino:34: undefined reference to ServoEasing::setEaseTo(int)'
C:\Users\stuar\Desktop\sketch_mar14a/sketch_mar14a.ino:35: undefined reference to synchronizeAllServosStartAndWaitForAllServosToStop()' C:\Users\stuar\Desktop\sketch_mar14a/sketch_mar14a.ino:40: undefined reference to ServoEasing::setEaseTo(int)'
C:\Users\stuar\Desktop\sketch_mar14a/sketch_mar14a.ino:41: undefined reference to ServoEasing::setEaseTo(int)' C:\Users\stuar\Desktop\sketch_mar14a/sketch_mar14a.ino:42: undefined reference to synchronizeAllServosStartAndWaitForAllServosToStop()'
C:\Users\stuar\AppData\Local\Temp\cclRWIGe.ltrans0.ltrans.o: In function _GLOBAL__sub_I_servoTop': C:\Users\stuar\Desktop\sketch_mar14a/sketch_mar14a.ino:2: undefined reference to ServoEasing::ServoEasing()'
C:\Users\stuar\Desktop\sketch_mar14a/sketch_mar14a.ino:3: undefined reference to `ServoEasing::ServoEasing()'
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

Thanks in advance

ServoEasing need the main servo library.
Are you installed the Servo.h library?

Hi, @sefuri385
Welcome to the forum.

What controller are you programming for?
Can you please post a link to where you got the "ServoEasing" library?

Is the library meant to be used with your controller?
Has the library got any examples for you to use first?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

You need change include to ServoEasing.hpp

From the library documentation:

The line #include <ServoEasing.h> must be changed to #include <ServoEasing.hpp> in your main program (aka *.ino file).

In all other files you must use #include <ServoEasing.h>, to prevent multiple definitions linker errors:

If you forget to include ServoEasing.hpp, you will see errors like Simple.ino:57: undefined reference to ServoEasing::attach(int, int).

Thanks very much, that worked - I think.

it got rid of all the errors and uploaded it, i did just get one thing saying:

avrdude: jtagmkII_initialize(): Cannot locate "flash" and "boot" memories in description

I am not sure if this is a problem or not, I guess I'll have to try wiring up the servos to see, but it did upload at least.

Thanks for your help.

Thanks for responding, the tip below did solve most of the error problems.

cheers
Stu

So please mark the thread solved

This message is normal output and can be ignored.

https://support.arduino.cc/hc/en-us/articles/4405239282578-avrdude-jtagmkII-initialize-Cannot-locate-flash-and-boot-memories-in-description

Thanks!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.