I'm trying to compile some code that is giving me an unresolved external symbol link error.
I have a static const float fDeg2Rad in class Math that I declare in the header and define in the source. The only place it is used at the moment is in a static inline function also in Math. If I remove the constant from the inline function the link error does not come up.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
//math.h
typedeffloat Real;
namespace Eris
{
class __declspec( dllexport ) Math
{
public:
staticinline Real DegreesToRadians(Real degrees)
{ return degrees * fDeg2Rad; }
staticconst Real PI;
staticconst Real fDeg2Rad;
};
}
1 2 3 4 5 6 7 8 9 10
//math.cpp
#include "ErisMath.h"
#include "ErisVector3.h"
namespace Eris
{
const Real Math::PI = Real( 4.0 * atan( 1.0 ) );
const Real Math::fDeg2Rad = PI / Real(180.0);
}
This is basically copied and pasted from the Ogre3D source code (http://www.ogre3d.org/), and while the Ogre3D code compiles fine, mine throws an unresolved external symbol for fDeg2Rad.
Edit: this is compiled as a dynamic link library on MSVS 2008, which is the reason for the __declspec( dllexport )