0

this is my files which I cut, but the essential is there

I have my file PID.h:

#ifndef PID_H_
#define PID_H_

class PID
{
    public:
        PID();
}

And my PID.cpp file:

#include "PID.h"

PID::PID(){

}

And my main.cpp:

#include "PID.h"
PID pid;

void setup(){}
void loop() {}

I'm wondering why I have this mistake:

C:\...\ccevwRea.ltrans0.ltrans.o: In function `_GLOBAL__sub_I_stairs':
<artificial>:(.text.startup+0x98): undefined reference to `PID::PID()'

Thanks !

cdhowie
  • 158,093
  • 24
  • 286
  • 300
Tom
  • 15
  • 3
  • 1
    Because you need to compile not only `main.cpp` but also `PID.cpp`. And add both objects (`.o`) to the linker command. – Ripi2 May 23 '20 at 17:49
  • 1
    Ripl2's probably right, but Alex, you can nail this down by adding the command line instructions used to build the program. – user4581301 May 23 '20 at 17:58

0 Answers0