I have a linking problem, i have a project that compiles in a dll:
header:
module:Code:#ifndef MESH_TOOL_H #define MESH_TOOL_H #include "Ogre.h" namespace Game { class _declspec(dllexport) MeshTool : public Ogre::Singleton<MeshTool> { public: MeshTool(); ~MeshTool(); void GetMeshInformation(const Ogre::Entity* const ent, size_t &vertex_count, Ogre::Vector3* &vertices, size_t &index_count, unsigned long* &indices, const Ogre::Vector3 &position, const Ogre::Quaternion &orient, const Ogre::Vector3 &scale); }; } #endif
from another project i use the dll and the header, when i compile the project i receive this error:Code:#include "MeshTool.h" using namespace Ogre; template<> Game::MeshTool* Ogre::Singleton<class Game::MeshTool>::ms_Singleton = 0; namespace Game { MeshTool::MeshTool() { }; MeshTool::~MeshTool() { }; void MeshTool::GetMeshInformation(const Entity* const ent, size_t &vertex_count, Vector3* &vertices, size_t &index_count, unsigned long* &indices, const Vector3 &position, const Quaternion &orient, const Vector3 &scale) { Implementation.... } }
The Ogre::Singleton is:Code:Error 6 error LNK2001: unresolved external symbol "protected: static class Game::MeshTool * Ogre::Singleton<class Game::MeshTool>::ms_Singleton" (?ms_Singleton@?$Singleton@VMeshTool@Game@@@Ogre@@1PAVMeshTool@Game@@A) PhysicsEngine.obj PhysEng
so i don't understand why it gives me that error.. i'm using that pointer (ms_Singleton) in PhysicsEngine in this way:Code:#ifndef _SINGLETON_H__ #define _SINGLETON_H__ // Added by Steve Streeting for Ogre #include "OgrePrerequisites.h" #if OGRE_COMPILER == OGRE_COMPILER_MSVC // Turn off warnings generated by this singleton implementation # pragma warning (disable : 4311) # pragma warning (disable : 4312) #endif #if defined ( OGRE_GCC_VISIBILITY ) # pragma GCC visibility push(default) #endif namespace Ogre { // End SJS additions /** Template class for creating single-instance global classes. */ template <typename T> class Singleton { protected: static T* ms_Singleton; public: Singleton( void ) { assert( !ms_Singleton ); #if defined( _MSC_VER ) && _MSC_VER < 1200 int offset = (int)(T*)1 - (int)(Singleton <T>*)(T*)1; ms_Singleton = (T*)((int)this + offset); #else ms_Singleton = static_cast< T* >( this ); #endif } ~Singleton( void ) { assert( ms_Singleton ); ms_Singleton = 0; } static T& getSingleton( void ) { assert( ms_Singleton ); return ( *ms_Singleton ); } static T* getSingletonPtr( void ) { return ms_Singleton; } }; } #if defined ( OGRE_GCC_VISIBILITY ) # pragma GCC visibility pop #endif #endif
Obviously i added MeshTools.lib in PhysicsEngine project and also the include directories.. so should i export in some way the template/property? how to do it?.Code:MeshTool::getSingletonPtr()->GetMeshInformation(ent, vertex_count, vertices, index_count, indices, pos ,orient , scale);
And another different question.. srry to mix things.. why Visual Studio never finds library or includes if i add their directories in Project->Options, but when i do it in Tools->Options etc it works?.



LinkBack URL
About LinkBacks



.