Compiling problem: undefined reference to `Servo::Servo()


I want to extend the standard Servo. So I define a new class EServo. When I try to compile it, I get this ]:slight_smile: errormsg:

EServo\EServo.cpp.o: In function `EServo':
C:\arduino\arduino-1.0.1\libraries\EServo/EServo.cpp:12: undefined reference to `Servo::Servo()'

Where did it all go wrong :frowning:

my H-file (EServo.h) looks like this:

#ifndef ESERVO_H
#define ESERVO_H

#include "../Servo/Servo.h"

class EServo : public Servo
    // construction
    EServo(unsigned int);
    void update(void);

    unsigned int myPortNumber;


and the CPP-file (EServo.cpp) looks like this:

#include <Arduino.h> 
#include "EServo.h"

EServo::EServo(unsigned int portNumber) :
  Servo(),    //line 12: ERROR: undefined reference to `Servo::Servo()
    //do something

void EServo::update(void)

Can somebody please HELP me???

Add this to your main sketch:

#include <Servo.h>

Also when including Servo.h inside EServo.h don’t put in the path. Let the IDE work that out.

Unbelieveable, it compiles!

Thank you Nick, for your correct and fast answer!

But do I understand it? No :(.

In the main sketch I included EServo.h: #include <EServo.h>
and in EServo.h, the first thing I do is include Servo.h.

This should make no difference, or am I wrong? Or is it an Arduino IDE-issue?

The IDE copies files to a temporary folder. Your includes in the main sketch informs the copy process. Since they are copied to one spot you don't need the "../" part.