I've a strange problem with linking a static member from a dll using Visual Studio Express 2010. On Linux platform
and MSYS/MinGW (GCC) this failure doesn't occurs.
I've a Math library using an export macro explicitly for this library module:
#ifdef WIN32 #ifdef MATH_LIBRARY_EXPORT #define MATH_LIBRARY_API __declspec(dllexport) #else #define MATH_LIBRARY_API __declspec(dllimport) #endif #else //define empty values for linux OS #define MATH_LIBRARY_API #endif
And this is a snipped of my Vector class i export with static members:
ifndef BINREV_VECTOR_H__
#define BINREV_VECTOR_H__
// include common header with dll import/export macro
#include <brMath/brCommons.h>
namespace binrev{
namespace brMath{
class MATH_LIBRARY_API brVector3f
{
public:
float m_fX, m_fY, m_fZ;
brVector3f(void);
brVector3f(float x, float y, float z);
...
public:
static const brVector3f ZERO;
static const brVector3f NEGATIVE_UNIT_X;
...
};
And the cpp module:
// Ensure that the dll hader will be exported
#define MATH_LIBRARY_EXPORT
#include <brMath/brVector3f.h>
namespace binrev{
namespace brMath{
const brVector3f brVector3f::ZERO(0.0f, 0.0f, 0.0f);
const brVector3f brVector3f::UNIT_X(1.0f, 0.0f, 0.0f);
...
In my Graphics module (also an dll with an different explicit
export macro) using this Math dll i try to access one of those
static members:
#include <brMath/brVector3f.h>
brMath::brVector3f brCamera::getDirection(void)
{
return m_orientation.rotate(brMath::brVector3f::NEGATIVE_UNIT_Z);
}
On the other platforms anything works well, but with MVSE 2010 i got
a linker failure:
1>------ Erstellen gestartet: Projekt: ZERO_CHECK, Konfiguration: Debug Win32 ------ 2>------ Erstellen gestartet: Projekt: brGraphics, Konfiguration: Debug Win32 ------ 2> brCamera.cpp 2>brCamera.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""public: static class binrev::brMath::brVector3f const binrev::brMath::brVector3f::NEGATIVE_UNIT_Z" (?NEGATIVE_UNIT_Z@brVector3f@brMath@binrev@@2V123@B)". 2>C:\binrev\repository\binrevengine\modules\brGraphics\trunk\bin\brGraphics.dll : fatal error LNK1120: 1 nicht aufgelöste externe Verweise. ========== Erstellen: 1 erfolgreich, Fehler bei 1, 0 aktuell, 0 übersprungen ==========
I'm not a friend of MVSE and this are my first tries to get our code runable
with MVSE. I've copied the brMath.lib and include files to the VC subfolder
of the MVSE home directory and also copy the brMath.dll to the output
directory where the brGraphics.dll should be build. I also imported the dll
as external file to the Visual Studio Solution explorer ...
Now i running out of ideas what could be wrong.
I'm grateful for any help or hint.












