Arduino servo not working when using wrapper and inheritance - c++

I'm building a robot arm which is quite complicated, so I wrote a class with inheritance to control different servos without having to write too much code. The classes look as follows (some stuff is left out):
In servoPart.h:
#include <Servo.h>
#ifndef SERVO_PART_H
#define SERVO_PART_H
class ServoPart {
protected:
virtual void doJob() = 0;
private:
Servo servo;
public:
ServoPart(int pin, int minPWM, int maxPWM) {
servo.attach(pin, minPWM, maxPWM);
};
void setAngle(int angle) {
servo.write(angle);
};
int getPosition() {
return servo.read();
};
}
#endif
And in base.h:
#include "servoPart.h"
#ifndef BASE_H
#define BASE_H
class Base : public ServoPart {
private:
void doJob() {/* implementation */};
public:
Base(int pin, int stepsize = 5) : ServoPart(pin, 771, 2193) {
};
};
#endif
And in main.cpp:
#include <Arduino.h>
#include "base.h"
#define SERVO_BASE 9
Base base(SERVO_BASE);
void setup() {
Serial.begin(9600);
delay(500);
base.setAngle(80);
Serial.println(base.getPosition()); // <-- prints 80
delay(500);
base.setAngle(110);
Serial.println(base.getPosition()); // <-- prints 110
}
void loop() {
}
The servo seems to be set to 80/110, however, nothing moves. If I create the servo object in the main.cpp and use servo.write() there, the servo moves, meaning the problem is not the servo or the connection/circuit. Is it possible that the fault lays in my way of initializing the base? Using Base base(SERVO_BASE) before the setup function?

I guess I'll clarify.
In C++ if you do not have a specified constructor, members get their default constructors called.
If the following code is not present
ServoPart(int pin, int minPWM, int maxPWM) {
servo.attach(pin, minPWM, maxPWM);
}
it is the equivalent of
ServoPart():servo() {}
The missing step is the default constructor for the Servo.
Solution that allows you to use the constructor is
ServoPart(int pin, int minPWM, int maxPWM):servo() {
servo.attach(pin, minPWM, maxPWM);
}

I found the solution here: When calling servo.attach() in the constructor, the order of variable initialization is messed up. Creating an init() function to be called in setup() solves this problem.

Related

((Thermostat*)this)->Thermostat::_dht' does not have class type

I'm trying to create an Arduino class named Thermostat, which uses the DHT library.
I think the error might be in a confusion I have regarding declaration of the _dht instance and initialising it.
My goal is just to have my main sketch clean and let the class Thermostat handle everything related to DHT.
Here is my sketch:
#include "Thermostat.h"
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
Here is my Thermostat.h file:
/*
Thermostat.h - Library for smart thermostat
*/
#ifndef Thermostat_h
#define Thermostat_h
#include "Arduino.h"
#include <DHT.h>
class Thermostat {
public:
Thermostat();
void DHTstart();
private:
DHT _dht(uint8_t, uint8_t); //// Initialize DHT sensor for normal 16mhz Arduino
};
// class initialization
Thermostat::Thermostat(){
_dht(7,DHT22);
}
void Thermostat::DHTstart(){
_dht.begin();
}
#endif
I'm getting the following error:
In file included from /Users/olmo/Documents/Arduino/debug_DTH_inClass/debug_DTH_inClass.ino:2:0:
sketch/Thermostat.h: In member function 'void Thermostat::DHTstart()':
Thermostat.h:24: error: '((Thermostat*)this)->Thermostat::_dht' does not have class type
_dht.begin();
^
exit status 1
'((Thermostat*)this)->Thermostat::_dht' does not have class type
It's almost correct, but DHT _dht(uint8_t, uint8_t); is the method prototype (instead of DHT instance). And you have to initialize this instance in the constructors initializer list:
class Thermostat {
public:
Thermostat();
void DHTstart();
private:
DHT _dht; //// Initialize DHT sensor for normal 16mhz Arduino
};
// class initialization
Thermostat::Thermostat()
: _dht(7,DHT22) // construct DHT instance with expected parameters
{ ; }
void Thermostat::DHTstart(){
_dht.begin();
}
or shorter version:
class Thermostat {
public:
Thermostat() : _dht(7, DHT22) {;}
void DHTstart() { _dht.begin(); }
private:
DHT _dht;
};
In this case (magic values for the DHT class) you can use c++11 features (since Arduino 1.6.5) and specify it directly, so the default constructor can be used:
class Thermostat {
public:
void DHTstart() { _dht.begin(); }
private:
DHT _dht{7, DHT22};
};

C++ multiple inheritance, multiple definition when there isn't?

I'm implementing hardware drivers for an embedded C/C++ project, and trying to make things a bit more flexible for future projects.
I have the vast majority of the work done in LCD.hpp/LCD.cpp, where there's a class that has five virtual functions. Four of these are for twiddling GPIO pins and sending SPI messages, and the fifth is for implementing various fonts. A shortened class declaration is as follows:
//LCD.hpp
#include <cstdint>
#ifndef LCD_HPP
#define LCD_HPP
class LCD {
public:
virtual void write_character(char what) = 0; //Stores data into a buffer in LCD through another function
protected:
virtual void SPI_TX(uint8_t *TXData, uint8_t length, bool ToBeContinued) = 0;
virtual void update_RST(bool pinstate) = 0;
virtual void update_DC(bool pinstate) = 0;
virtual void update_backlight(uint8_t brightness) = 0;
};
#endif
Moving on, I implemented a font-printing write_character as such.
//LCD_FixedWidth.hpp
#include <cstdint>
#include "LCD.hpp"
#ifndef LCD_FIXEDWIDTH_HPP
#define LCD_FIXEDWIDTH_HPP
class LCD_FixedWidth : virtual public LCD {
public:
void write_character(char what);
};
#endif
Now it's time for the various hardware bits.
//LCD_hardware.hpp
#include <cstdint>
#include "LCD.hpp"
#include "LCD_FixedWidth.hpp"
#ifndef LCD_HARDWARE_HPP
#define LCD_HARDWARE_HPP
class LCD_hardware : virtual public LCD {
protected:
void SPI_TX(uint8_t *TXData, uint8_t length, bool ToBeContinued);
void update_RST(bool pinstate);
void update_DC(bool pinstate);
void update_backlight(uint8_t brightness);
};
And then a class to tie it all together, still in LCD_hardware.hpp...
class LCD_meta : public LCD_hardware, public LCD_FixedWidth {
public:
void write_character(char what) { LCD_FixedWidth::write_character(what); };
protected:
void SPI_TX(uint8_t *TXData, uint8_t length, bool ToBeContinued) { LCD_hardware::SPI_TX(TXData, length, ToBeContinued); };
void update_RST(bool pinstate) { LCD_hardware::update_RST(pinstate); };
void update_DC(bool pinstate) { LCD_hardware::update_DC(pinstate); };
void update_backlight(uint8_t brightness) { LCD_hardware::update_backlight(brightness); };
};
#endif
And for all of this, I get a multiple definition of LCD_FixedWidth::write_character(char) error. Anybody see anything I'm missing here? All of my headers are guarded properly, and I can only see one implementation of write_character...
This was caused by having LCD_meta and LCD_hardware in the same header file. The code for the LCD_hardware functions was in an implementation file, so the LCD_meta class didn't actually have those functions defined yet... One class per file!

C++ Event handler with derived classes through a base class array

I have been trying to make a game engine for some time, and for the most part it has been turning out quite well, considering it's the first one i've made. But when I started to make an event send/recieve system with derived classes contained in a base class pointer vector array, I had some trouble making the reciever get the class type and use the proper function; here's what I have:
This is my base class Object:
object.h:
#include "all.h" //Contains '#include "SDL/SDL.h"' and constant variables.
#include <vector>
#include "mask.h" //An unimportant class used for collision checking
class Body;
class Room;
class Object//Objects that belong here are those without step events.
{
public:
vector<vector<Room> > *world_map;//Should hold the address of the world map.
Room *room;//The room holding this object.
unsigned int x;
unsigned int y;
unsigned int pos;//Position of the object in the room's list.
int depth;//The deeper it is, the later it will be drawn.
virtual void draw(SDL_Surface *buffer,int viewx, int viewy){}
virtual void interact(Body *body);//Sends a pointer of this object to the
//the obj_event function of the body calling it.
Object(unsigned int xx=0, unsigned int yy=0,int d=0):x(xx),y(yy),depth(d){}
};
#endif // INSTANCE_H_INCLUDED
object.cpp:
#include "object.h"
#include "body.h"
void Object::interact(Body *body)
{
body->obj_event(this);
}
This is my derived class Body:
body.h:
#ifndef BODY_H_INCLUDED
#define BODY_H_INCLUDED
#include "all.h"
#include "object.h"
class Entity;
class Enemy;
class Player;
class Body : public Object//Objects that belong here are those with step events.
{
public:
int priority;//Decides which body will perform their step event first.
virtual void step()=0;
Body(int xx=0, int yy=0, int d=0, int p=0):Object(xx,yy,d),priority(p){}
//These scripts are for handling objects and bodies it has called through
//interact()
virtual void obj_event(Object *object){}
virtual void obj_event(Entity *entity){}
virtual void obj_event(Enemy *enemy){}
virtual void obj_event(Player *player){}
};
#endif // BODY_H_INCLUDED
there is no body.cpp
This is my derived class of Body, Entity:
entity.h:
#ifndef ENTITY_H_INCLUDED
#define ENTITY_H_INCLUDED
#include "all.h"
#include "body.h"
#include "items.h"
#include <vector>
#include "mask.h"
class Entity : public Body
{
public:
vector<Item> inv;
unsigned int width;
unsigned int height;
Mask mask;
Entity(int xx,int yy,int w,int h,int d=0,int p=0);
void step();
void collide_action(Entity *entity);
virtual void obj_event(Player *player);
virtual void obj_event(Enemy *enemy);
};
#endif // ENTITY_H_INCLUDED
entity.cpp:
#include "entity.h"
#include "room.h"
#include "player.h"
#include "enemy.h"
Entity::Entity(int xx,int yy,int w,int h,int d,int p):Body(xx,yy,d,p),width(w),height(h),mask(xx,yy,w,h,m_rectangle)
{}
void Entity::step()
{
for(int iii=0;iii<room->inv.size();iii++)//Iterates through objects
{
room->inv[iii]->interact(this);
mask.update(x,y,width,height);
}
for(int iii=0;iii<room->index.size();iii++)//Iterates through bodies
{
room->index[iii]->interact(this);
mask.update(x,y,width,height);
}
}
void Entity::collide_action(Entity *entity)
{
if(entity!=this)
{
if (mask_collide(mask,entity->mask))
{
short xchange;
short ychange;
if (entity->x<x)
{
xchange=width-(x-entity->x);
}
else
{
xchange=(entity->x-x)-width;
}
if (entity->y<y)
{
ychange=height-(y-entity->y);
}
else
{
ychange=(entity->y-y)-height;
}
if(abs(xchange)<abs(ychange))
x+=xchange;
else
y+=ychange;
}
}
}
void Entity::obj_event(Player *player)
{
collide_action(player);
}
void Entity::obj_event(Enemy *enemy)
{
collide_action(enemy);
}
This is my derived class of Entity, Player:
player.h:
#ifndef PLAYER_H_INCLUDED
#define PLAYER_H_INCLUDED
#include "all.h"
#include "body.h"
#include "items.h"
#include <vector>
#include "mask.h"
#include "entity.h"
enum keylist
{
kl_left=0,
kl_up=1,
kl_right=2,
kl_down=3,
};
class Player : public Entity
{
public:
SDLKey keys[4]; //List of action's corresponding keys.
Player(int xx,int yy,int w,int h,int d=0,int p=0);
void step();
void draw(SDL_Surface *buffer,int viewx,int viewy);
void interact(Body *body);
};
#endif // PLAYER_H_INCLUDED
player.cpp:
#include "player.h"
#include "room.h"
Player::Player(int xx,int yy,int ww,int hh,int dd,int pp):Entity(xx,yy,ww,hh,dd,pp)
{
//Default keys, can be changed.
keys[kl_left]=SDLK_LEFT;
keys[kl_up]=SDLK_UP;
keys[kl_right]=SDLK_RIGHT;
keys[kl_down]=SDLK_DOWN;
}
void Player::step()
{
Uint8 *key=SDL_GetKeyState(NULL);
if (key[keys[kl_left]])
x-=1;
if (key[keys[kl_right]])
x+=1;
if (key[keys[kl_up]])
y-=1;
if (key[keys[kl_down]])
y+=1;
mask.update(x,y,width,height);
Entity::step();
}
void Player::draw(SDL_Surface *buffer,int viewx,int viewy)
{
FillRect(buffer,x-viewx,y-viewy,width,height,0xFF0000);
}
void Player::interact(Body *body){body->obj_event(this);}
I have another class Enemy, but it's pretty much exactly like player (without the keyboard controls).
Now here's my problem (not error), for every object I want any body to perform an event for, I need to make virtual functions of ALL of them in this base class, that way if any object calls body->obj_event(this), it will pick the proper function with the most derived argument.
For example, if Player called object->interact(this) of an enemy, the enemy would first use it's base class Object's virtual function interact(Body*), which would then check the derived classes if they have an identical function (which enemy does), and then enemy calls body->obj_event(this) of the player body through it's base class, Body. The player body would then first use it's base class Body's virtual function obj_event(Enemy*), which would then check the derived classes if they have an identical function (which Entity does), and then Entity executes obj_event(Enemy*). At least that's how I understand it.
What I'd like to have is a way for any derived class to call interact of any other derived class through it's base function, and would then have it call it's obj_event function for the derived class, without having to have any of the Base classes know about their derived classes.
As I mentioned, this is my first time making an engine, and I'm probably using methods that are completely hectic and error-prone. I was thinking that templates might be able to help out in this situation, but don't know how to implement them.

Pointers, Class Items and Scope

I can't seem to find the answer but maybe I'm searching the wrong terminology. I am not finding the answer I am looking for in the hits.
I have a bunch of derived classes for a menu system.
I have a CControl derived class that is parent of a CEditBox and a CLabel class. CLabel is nothing more than attaching the text onto an SDL_Surface and then binding it to a texture for openGL to render. CEditBox would be a field for displaying text or gathering text from users like a password box. Obviously, CEditBox could make use of a label for handling the text rendering inside the box. CControl is derived from CComponent.
I cannot declare CLabel inside CEditBox unless I include CLabel in the header but I think I keep getting linker errors doing that even though I have all of my headers wrapped in #ifndef #define class #endif syntax but I'm also a noob. Instead, I have a CComponent* pointer declared since they are derived from that class.
Fine. Now in the constructor for the CEditBox I have:
#include "CLabel.h" //include in .CPP is fine I reckon.
CEditBox::CEditBox() {
CLabel Field; //Create CLabel
InputType = ALL; //Not important for my question related to allowed symbols
Label = &Field; //CComponent pointer to CLabel
}
When this constructor function returns, wouldn't CLabel go out of scope, and thus Feild would be destroyed and now my pointer is pointing at an undefined block of memory? What would be an appropriate way to do this? Is there a better solution?
Thank you
Linker problem
I don't know that the problem exists anymore, but some think this is a more important issue. Well here is the actual code now and you guys can tell me if you think it is done incorrectly.
Base Class CMenuObject
#ifndef _CMENUOBJECT_H_
#define _CMENUOBJECT_H_
class CMenuObject {
protected:
const char* ClassName;
public:
CMenuObject();
virtual const char* Object();
};
#endif
Next Class is CComponent
#ifndef _CCOMPONENT_H_
#define _CCOMPONENT_H_
#include "CMenuObject.h"
class CComponent : public CMenuObject {
protected:
const char* _Name;
int _Tag;
static int _ComponentCount;
static int _IDCount;
public:
CComponent();
virtual const char* Name();
virtual int Tag();
virtual void Tag(int t);
};
#endif
Then comes CControl These would be objects that users would interact with or in some way need control the display (i.e. a timer doesn't need user input) and is a mammoth. Don't mind the function pointer stuff because I have no idea what i'm doing with that yet.. this is my first guess approach to handling events. I think it's limiting because I can't figure out what to do if the function needs to take a parameter but I may not have to, etc... We can gloss over this detail for now.
#ifndef _CCONTROL_H_
#define _CCONTROL_H_
#include "CComponent.h"
class CControl : public CComponent {
protected:
int _X,_Y,_Width,_Height;
float R,G,B,A;
void (*OnClk)();
void (*OnDblClk)();
void (*OnMOver)();
void (*OnMHover)();
void (*OnKDown)();
void (*OnKUp)();
void (*OnFcs)();
bool Visible;
CComponent* Pappy;
public:
CControl();
//Render Control
virtual void Show(); // Show Component
virtual void Hide(); // Hide Component
virtual void OnRender(); // Render Component
virtual bool IsVisible(); // Get Current Visibility Status
//Paramater Control
//Write
virtual void X(int x); // Set Component's X coordinate
virtual void Y(int y); // Set Component's Y coordinate
virtual void Width(int w); // Set Component's Width
virtual void Height(int h); // Set Component's Height
//Read
virtual int X(); // Get Component's X coordinate
virtual int Y(); // Get Component's Y coordinate
virtual int Width(); // Get Component's Width
virtual int Height(); // Get Component's Height
//Display Control
virtual void Color(float r, float g, float b); // Set Color of Component- Multicolored objects, this will be the base or bkg color. Makes alpha 1.0f.
virtual void Color(float r, float g, float b, float a); // Same as above but allows for input of an alpha value.
//Font Control
virtual void FontName(const char* font); // Name of font to use
virtual void FontSize(int pt); // Pt size of font. Or maybe pixel, no idea.
virtual void Text(const char* msg); // Text message to render
//Read
virtual const char* Text(); // Read Text Message
//Interactive Control // These will register call back functions for user events
virtual void OnClick(void (*func)()); // On Single Click
virtual void OnDoubleClick(void (*func)()); // On Double Click
virtual void OnMouseOver(void (*func)()); // On Mouse Over
virtual void OnMouseHover(void (*func)()); // On Mouse Hover
virtual void OnKeyDown(void (*func)()); // On Key Down
virtual void OnKeyUp(void (*func)()); // On Key Up
virtual void OnFocus(void (*func)()); // On Focus
//Other
virtual void Parent(CComponent); // Set Parent
virtual CComponent* Parent(); // Get Parent
};
#endif
Finally my end game headers of CLabel and CEditBox.
#ifndef _CLABEL_H_
#define _CLABEL_H_
#include "CTexture.h"
#include "CFont.h"
#include "CControl.h"
class CLabel : public CControl {
private:
const char* vText;
CFont Font;
CTexture Text_Font;
SDL_Surface* Surf_Text;
int X,Y,vWidth,vHeight;
public:
CLabel();
CLabel(const char* text);
virtual void OnRender();
virtual void OnCleanup();
virtual void Text(const char* msg);
virtual const char* Text();
virtual void FontName(const char* fname);
virtual void FontSize(int pt);
virtual void FontColor(float r, float g, float b);
};
#endif
AND
#ifndef _CEDITBOX_H_
#define _CEDITBOX_H_
#include "CControl.h"
class CEditBox : public CControl {
protected:
CComponent* Label;
int InputType;
public:
CEditBox();
~CEditBox();
virtual void OnRender();
//virtual void OnCleanup();
virtual void OnLoop();
virtual void Text(const char* msg);
virtual const char* Text();
virtual void FontColor(float r, float g, float b);
virtual void OnClick(void (*func)()); // On Single Click
virtual void OnDoubleClick(void (*func)()); // On Double Click
virtual void OnMouseOver(void (*func)()); // On Mouse Over
virtual void OnMouseHover(void (*func)()); // On Mouse Hover
virtual void OnKeyDown(void (*func)()); // On Key Down
virtual void OnKeyUp(void (*func)()); // On Key Up
virtual void OnFocus(void (*func)()); // On Focus
enum {
ALL = 0, //abcdefghijklmnopqrstuvwxyz (and caps) 1234567890!##$%^&*()_+-=[]{}<>\/|"';:,.?
ALPHA_NUMERIC, //abcdefghijklmnopqrstuvwxyz (and caps) 1234567890
ALPHA, //abcdefghijklmnopqrstuvwxyz (and caps)
NUMERIC, //1234567890
PASSWORD, //abcdefghijklmnopqrstuvwxyz (and caps) 1234567890!##$%&. -- Render as *
IP //1234567890 . Maybe fix feild width and force xxx.xxx.xxx.xxx format.
};
};
#endif
[SOLVED]
Today, I found the one dang header not wrapped in #ifndef #define #endif. (it was CTexture which gets called again in CFont. Anyway, the restructure was also incredibly beneficial because I've figured out how to use inheritance and base class pointers, and how derived classes can work with each other. Not to mention many many more things. :)
The route I'm taking for derived class interplay is using a base class pointer that can access the derived classes functions via virtual functions. I use new and delete because that's what I am comfortable with. For everyone that contributed, thank you! They are all good answers.
Stereo typical approaches would be:
the pimpl idiom (Why should the "PIMPL" idiom be used?)
using unique_ptr (Rule of Zero)
Showing the second approach:
//////////// CEditBox.hpp header file
#include <memory>
#include <string>
class CLabel; // forward declaration
class CEditBox
{
public:
CEditBox(std::string const&);
private:
std::unique_ptr<CLabel> _label;
};
The forward declaration avoids the need to include CLabel.hpp. The unique_ptr manages the lifetime _label so we don't have to remember to delete it.
//////////// CLabel.hpp header file
#include <string>
#include "CLabel.hpp"
class CLabel
{
public:
CLabel(std::string const& name)
: _name(name)
{
}
private:
std::string _name;
};
Just a sample, nothing to see here. Let's move on:
///////////// CEditBox.cpp source file
#include "CEditBox.hpp"
#include "CLabel.hpp"
CEditBox::CEditBox(std::string const& name)
: _label(new CLabel(name))
{
}
That's the magic: we integrate it all by include CLabel.hpp as well, and construct it in the initializer list.
///////////// main.cpp source file
#include "CEditBox.hpp"
int main()
{
CEditBox box("Hello world"); // no need to 'know' CLabel here
}
Proof of the pudding is in the compilation: http://ideone.com/zFrJa8
Your thinking is on the correct track. The right approach would be allocating this object dynamically, i.e.
Label = new CLabel;
Don't forget to free memory in destructor:
delete Label;
If I understand your problem correctly, you have two classes which have member variables with each other's class?
For instance:
// A.h
#ifndef A_H
#define A_H
#include "B.h"
class A {
public:
...
private:
B* pB;
};
#endif // A_H
And:
// B.h
#ifndef B_H
#define B_H
#include "A.h"
class B {
public:
...
private:
A* pA;
};
#endif // B_H
And compiling these together causes some form of linker error? If this is the case you can circumvent this by forward declaring the class, so instead of including A.h and B.h you simple write class B; above your declaration of class A and class A; above your declaration of class B, then include the headers in your cpp files. So A.h would look like:
// A.h
#ifndef A_H
#define A_H
class B;
class A {
public:
...
private:
B* pB;
};
#endif // A_H
CLabel Field; should be a member of CEditBox. The real question is the one where you mention 'linker errors' (or whatever it is). That's the problem you should be solving.

C++ inheritance problem with namespaces

OK, I have been looking about but can not for the wits of me find a reason to why this should not work:
Base class (misc/interface/handler.h)
#ifndef __t__MISC_VIRTUAL_HANDLER_H
#define __t__MISC_VIRTUAL_HANDLER_H
#pragma message("Starting with 'handler.h'")
namespace t {
namespace misc {
namespace interface {
class Handler {
public:
Handler();
virtual ~Handler();
virtual int setup() = 0;
virtual int teardown() = 0;
virtual int update() = 0;
protected:
private:
};
}
}
}
#pragma message("Ending with 'handler.h'")
#endif // __t__MISC_VIRTUAL_HANDLER_H
Derived class (graphics/handler.h):
#ifndef __t_GRAPHICS_HANDLER_H
#define __t_GRAPHICS_HANDLER_H
#include "../misc/interface/handler.h"
namespace t {
namespace graphics {
class Handler: public t::misc::interface::Handler {
public:
Handler();
virtual ~Handler();
int getResolutionX() { return m_resolutionX; }
int getResolutionY() { return m_resolutionY; }
bool getFullscreen() { return m_isFullscreen; }
protected:
private:
unsigned int m_resolutionX, m_resolutionY;
bool m_isFullscreen;
}; // class Handler
} // namespace graphics
} // namespace t
#endif // __t_GRAPHICS_HANDLER_H
... which seems rather trivial.
Derived class implementation (graphics/handler.cpp):
#include "handler.h"
t::graphics::Handler::Handler(): t::misc::interface::Handler() {
}
t::graphics::Handler::~Handler() {
}
... which too is should be really trivial, but yields the error:
src\graphics\handler.cpp|5|undefined reference to `t::misc::interface::Handler::Handler()'
I'm using MinGW with Code Blocks and what ever standard settings CB uses, I've tried building the same situation with test classes and that works as intended, both in same environment and Linux with vanilla g++.
I can't see any implementation of t::misc::interface::Handler::Handler() in your code - and it is going to be called by the inheriting class's constructor, so it needs an implementation. The linker can't find it, so it complains.
Just change:
Handler();
virtual ~Handler();
in the abstract class to:
Handler() {}
virtual ~Handler() {}
and you're ready to go.
As an aside, identifiers starting with two underscores are illegal in C++ (since they are reserved for the compiler). In practice, they shouldn’t be a problem in preprocessor but it’s best to err on the safe side here: simply don’t use them.