A problem with linking

zcout

23-02-2011 21:02:28

Hey guys,

I get into following problem when I try to run my application:

/home/mk/OgreApp/OgreApp: symbol lookup error: /home/mk/OgreApp/OgreApp: undefined symbol: _ZN5MyGUI9SingletonINS_11DataManagerEE10msInstanceE

There are no logs written out, because the application apparently crashes even before any OGRE stuff can be initialized.

The app crashes after adding the MyGUI initialization from this wikipage http://www.ogre3d.org/tikiwiki/MyGUI+quickstart.

Everything compiles fine except some load of warnings...

Any idea what can be wrong?

MyGUI version (according to included changelog) is 3.2.0 RC1
Compiled with OGRE 1.7.2 on Linux

Related code:
#include "App.h"
#include "global.h"
#include <OgreWindowEventUtilities.h>

App::App() : mRoot(0)
{

}

App::~App()
{
//Remove ourself as a Window listener
Ogre::WindowEventUtilities::removeWindowEventListener(mWindow, this);
windowClosed(mWindow);

/*gui->shutdown();
delete gui;
gui = 0;
ogreGuiPlatform->shutdown();
delete ogreGuiPlatform;
ogreGuiPlatform = 0;*/

delete mRoot;
}

bool App::go()
{
// construct Ogre::Root
#ifdef lin64
#define pluginsFile "cfg/plugins_lin64.cfg"
#endif

#ifdef lin32
#define pluginsFile "cfg/plugins_lin32.cfg"
#endif

#ifdef win32
#define pluginsFile "cfg/plugins_win32.cfg"
#endif

mRoot = new Ogre::Root(qs2os(sep(pluginsFile)), qs2os(sep("cfg/ogre.cfg")), qs2os(sep("log/ogre.log")));

// load resources
Ogre::ConfigFile cf;
cf.load(qs2os(sep("cfg/resources.cfg")));

Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();

Ogre::String secName, typeName, archName;
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName);
}
}

// OGRE config dialog
//TODO: rewrite for automatic detection, see http://www.ogre3d.org/tikiwiki/Basic+Tu ... nderSystem
Ogre::RenderSystem *rs = mRoot->getRenderSystemByName("OpenGL Rendering Subsystem");
//RenderSystem *rs = mRoot->getRenderSystemByName("Direct3D9 Rendering Subsystem");
mRoot->setRenderSystem(rs);
rs->setConfigOption("Full Screen", "No");
rs->setConfigOption("Video Mode", "1024 x 768 @ 32-bit colour");

// setup a window
//TODO: replace with the real game name
mWindow = mRoot->initialise(true, "Space / Universum / Whatever");

// Set default mipmap level (NB some APIs ignore this)
Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
// initialise all resource groups
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

// Create the SceneManager
mSceneMgr = mRoot->createSceneManager("DefaultSceneManager");

// Prepare GUI
ogreGuiPlatform = new MyGUI::OgrePlatform();
ogreGuiPlatform->initialise(mRoot->getAutoCreatedWindow(), mSceneMgr);
gui = new MyGUI::Gui();
gui->initialise();

// Create the camera
mCamera = mSceneMgr->createCamera("PlayerCam");

// Position it at 500 in Z direction
mCamera->setPosition(Ogre::Vector3(0,0,80));
// Look back along -Z
mCamera->lookAt(Ogre::Vector3(-300,0,0));
mCamera->setNearClipDistance(5);

// Create one viewport, entire window
Ogre::Viewport* vp = mWindow->addViewport(mCamera);
vp->setBackgroundColour(Ogre::ColourValue(0,0,0));

// Alter the camera aspect ratio to match the viewport
//mCamera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight())); // crashes the application if a skybox is added after this

// skybox to see something
mSceneMgr->setSkyBox(true, "skyboxes/system_a");

// OIS
Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
size_t windowHnd = 0;
std::ostringstream windowHndStr;
OIS::ParamList pl;
Ogre::RenderWindow *win = mRoot->getAutoCreatedWindow();

win->getCustomAttribute("WINDOW", &windowHnd);
windowHndStr << windowHnd;
pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
pl.insert(std::make_pair(std::string("x11_mouse_grab"), std::string("false")));
mInputManager = OIS::InputManager::createInputSystem(pl);

try
{
mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, true));
mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, true));
}
catch (const OIS::Exception &e)
{
throw Ogre::Exception(42, e.eText, "Application::setupInputSystem");
}

//Set initial mouse clipping size
windowResized(mWindow);

//Register as a Window listener
Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);

mRoot->addFrameListener(this);

mRoot->startRendering();

return true;
}

//Adjust mouse clipping area
void App::windowResized(Ogre::RenderWindow* rw)
{
unsigned int width, height, depth;
int left, top;
rw->getMetrics(width, height, depth, left, top);

const OIS::MouseState &ms = mMouse->getMouseState();
ms.width = width;
ms.height = height;
}

//Unattach OIS before window shutdown (very important under Linux)
void App::windowClosed(Ogre::RenderWindow* rw)
{
//Only close for window that created OIS (the main window in these demos)
if( rw == mWindow )
{
if( mInputManager )
{
mInputManager->destroyInputObject( mMouse );
mInputManager->destroyInputObject( mKeyboard );

OIS::InputManager::destroyInputSystem(mInputManager);
mInputManager = 0;
}
}
}

bool App::frameRenderingQueued(const Ogre::FrameEvent& evt)
{
if(mWindow->isClosed())
return false;

// Need to capture/update each device
mKeyboard->capture();
mMouse->capture();

if(mKeyboard->isKeyDown(OIS::KC_ESCAPE))
return false;

return true;
}

Garthy

24-02-2011 07:42:00

What do you get when you run:


ldd /home/mk/OgreApp/OgreApp


?

Do you have multiple versions of Ogre/MyGUI on your system?

What were the warnings when you compiled? They're probably significant.

Is LD_LIBRARY_PATH set correctly, or have you installed MyGUI to some place the dynamic linker can find it?

Did you link to both MyGUIEngine and MyGUI.OgrePlatform?

zcout

02-03-2011 14:22:44

Good guess, I was linking libraries from the system (I wasn't even aware of them) instead of my project ones. Thanks!

Garthy

02-03-2011 23:21:57

Good guess, I was linking libraries from the system (I wasn't even aware of them) instead of my project ones. Thanks!

No probs, happy to help. :)