These annoying errors have been haunting me the last couple of days, so I figured I should share the most common reason for their occurrence. That is in my projects at least.
This error is caused because the linker in gcc is unable to find the functions you have defined in your headers in your actual code. So if you have a header which looks like this:
#ifndef MESH_H #define MESH_H class Mesh { public: Mesh(); ~Mesh(); virtual void draw(); }; #endif // MESH_H
You must at least have these functions defined in your .cpp file:
#include "mesh.h" Mesh::Mesh() { } Mesh::~Mesh() { } void Mesh::draw() { }
After this, make sure you clean your compile environment to make sure no object files are being misinterpreted by the compiler. If you are using Qt or a project with a Makefile, you could just run these three commands (the first only applies to Qt projects).
qmake make clean make
