At first I would like to point out that I'm new to linking, libraries and stuff.
I'm trying to implement simple math library (dynamic) for vectors and matrices. I'm using Visual Studio. Let's say I have 2 projects, one si DLL and other is console app to test it.
I've declared preprocessor macro for export:
#define GE_API __declspec(dllexport)
This is my matrix class:
class GE_API float4x4
{
public:
// The four columns of the matrix
float4 c1;
float4 c2;
float4 c3;
float4 c4;
/**
*/
float4& operator [] (const size_t i);
const float4& operator [] (const size_t i) const;
/**
* Index into matrix, valid ranges are [1,4], [1,4]
*/
const float &operator()(const size_t row, const size_t column) const { return *(&(&c1 + column - 1)->x + row - 1); }
float &operator()(const size_t row, const size_t column) { return *(&(&c1 + column - 1)->x + row - 1); }
/**
*/
bool operator == (const float4x4& m) const;
/**
*/
bool operator != (const float4x4& m) const;
/**
*/
const float4 row(int i) const;
/**
* Component wise addition.
*/
const float4x4 operator + (const float4x4& m);
/**
* Component wise scale.
*/
const float4x4 operator * (const float& s) const;
/**
* Multiplication by column vector.
*/
const float4 operator * (const float4& v) const;
/**
*/
const float4x4 operator * (const float4x4& m) const;
/**
*/
//const float3 &getTranslation() const { return *reinterpret_cast<const float3 *>(&c4); }
const float3 getTranslation() const
{
return make_vector(c4.x, c4.y, c4.z);
}
};
/**
*/
template <>
const float4x4 make_identity<float4x4>();
Problem is that when I try to compile I get unresolved eternal symbols error. I guess that its because class float4x4
gets exported but function make_identity does not. But if thats right how can I export function make_identity()
?