artn3r
11-11-2008 14:02:05
I am trying to "Singletonize" the NxOgre::World class, because i want to use it in my application, which can script in python using python-ogre.
I want to create the World object in Python and then in C++ i want to get
the singleton of World to access the same World object as in Python.
In the code of the World-class, there is already an include for "OgreSingleton.h", but there is no "ms_Singleton" pointer declared,
maybe the code is not finished yet? The World class does also not inherit
the Ogre::Singleton class.
So in NxOgreWorld.h i changed:
to
In NxOgreWorld.cpp i added:
The code compiles fine!
But when i add my new compiled .lib and .dll file to my project
and call NxOgre::World::getSingleton(); then, the linker gives me
the error:
""protected: static class NxOgre::World * Ogre::Singleton<class NxOgre::World>::ms_Singleton" (?ms_Singleton@?$Singleton@VWorld@NxOgre@@@Ogre@@1PAVWorld@NxOgre@@A)".
1>bin\Release\3DIS-Client.exe : fatal error LNK1120: 1 not resolved external references.
I do not know why, because i did this procedure with all my classes
in my application and it worked fine! I just added the : public Ogre::Singleton to the class declaration in the .h file and the ms_Singleton pointer to my .cpp file.
I use Visual Studio 2008 and NxOgre 1.0 '21 from the SVN!
I want to create the World object in Python and then in C++ i want to get
the singleton of World to access the same World object as in Python.
In the code of the World-class, there is already an include for "OgreSingleton.h", but there is no "ms_Singleton" pointer declared,
maybe the code is not finished yet? The World class does also not inherit
the Ogre::Singleton class.
So in NxOgreWorld.h i changed:
class NxPublicClass World {
to
class NxPublicClass World : public Ogre::Singleton<World> {
In NxOgreWorld.cpp i added:
NxOgre::World* Ogre::Singleton<NxOgre::World>::ms_Singleton;
, now the class looks like this:
#include "NxOgreStable.h"
#include "NxOgreWorld.h"
#include "NxOgreScene.h" // For: Scene operations
#include "NxOgreHelpers.h" // For: Incase of Scene duplicate names.
#include "NxOgreDebugRenderer.h" // For: Times when it's really needed.
#include "time.h" // For: Making sure NxGenerateID is random.
#if (NX_USE_OGRE == 1)
# include "OgreRoot.h"
# include "OgreSingleton.h"
#endif
NxOgre::World* Ogre::Singleton<NxOgre::World>::ms_Singleton;
namespace NxOgre {
World::World(PhysXParams driverParams, bool loadResources) {
mDriver = NxNew(PhysXDriver)(this, driverParams);
mNbFrames = 0;
srand((unsigned)time(0));
#if (NX_USE_DEBUG_RENDERER_API == 1)
mDebugRenderer = 0;
#endif
// mSerialiser = new Serialiser(this);
NxLabelContainer(World, mScenes, Scenes);
}
///////////////////////////////////////////////////////////////////////
World::~World() {
shutdown();
}
.
.
.
The code compiles fine!
But when i add my new compiled .lib and .dll file to my project
and call NxOgre::World::getSingleton(); then, the linker gives me
the error:
""protected: static class NxOgre::World * Ogre::Singleton<class NxOgre::World>::ms_Singleton" (?ms_Singleton@?$Singleton@VWorld@NxOgre@@@Ogre@@1PAVWorld@NxOgre@@A)".
1>bin\Release\3DIS-Client.exe : fatal error LNK1120: 1 not resolved external references.
I do not know why, because i did this procedure with all my classes
in my application and it worked fine! I just added the : public Ogre::Singleton to the class declaration in the .h file and the ms_Singleton pointer to my .cpp file.
I use Visual Studio 2008 and NxOgre 1.0 '21 from the SVN!