I'm programming a game engine in C++, mostly for educational purposes. I have a custom generic array class (mostly so that I can add better handling of dynamic allocation later) and everything compiles fine, but when I try to link I get this:
libsurvive/bin/debug/libsurvive.so: undefined reference to `Survive::System::Array<Survive::Math::Vector3>::~Array()'
libsurvive/bin/debug/libsurvive.so: undefined reference to `Survive::System::Array<Survive::Math::Vector2>::~Array()'
libsurvive/bin/debug/libsurvive.so: undefined reference to `Survive::System::Array<Survive::Math::Vector3>::Array()'
libsurvive/bin/debug/libsurvive.so: undefined reference to `Survive::System::Array<Survive::Math::Vector3>::resize(unsigned long)'
libsurvive/bin/debug/libsurvive.so: undefined reference to `Survive::System::Array<Survive::Math::Vector3>::size() const'
libsurvive/bin/debug/libsurvive.so: undefined reference to `Survive::System::Array<Survive::Math::Vector2>::Array()'
libsurvive/bin/debug/libsurvive.so: undefined reference to `Survive::System::Array<Survive::Math::Vector2>::resize(unsigned long)'
libsurvive/bin/debug/libsurvive.so: undefined reference to `Survive::System::Array<Survive::Math::Vector3>::operator[](unsigned long)'
libsurvive/bin/debug/libsurvive.so: undefined reference to `Survive::System::Array<Survive::Math::Vector3>::clear()'
libsurvive/bin/debug/libsurvive.so: undefined reference to `Survive::System::Array<Survive::Math::Vector2>::clear()'
libsurvive/bin/debug/libsurvive.so: undefined reference to `Survive::System::Array<Survive::Math::Vector2>::size() const'
what is interesting about this is that the only errors seem to be with constructors/destructors and with functions that use 'size_t.' Anyway, here's the definition of the array class:
#include <stddef.h>
namespace Survive {
namespace System {
template<typename Type>
class Array {
public:
Array();
Array(size_t size);
~Array();
void add(Type item);
void clear();
size_t size() const;
Type &operator[](size_t i);
void resize(size_t newSize);
private:
Type *pointer;
size_t capacity;
size_t numElements;
};
}
}
I'm using g++ and makefiles generated by premake.
Anyone have any idea on how to fix this problem?
Thanks in advance!