Page 1 of 2
[solved]Compiling error in CEGUIString.h
Posted: Sat May 09, 2009 12:49
by Hedgehog
Hey.
I just upgraded to Ogre 1.6.2 and now when I try to compile my project I get this error output:
Code: Select all
1>------ Build started: Project: herbert_game, Configuration: Debug Win32 ------
1>Compiling...
1>cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release
1>herbert_game.cpp
1>c:\ogresdk\include\cegui\ceguistring.h(644) : error C2059: syntax error : 'constant'
1>c:\ogresdk\include\cegui\ceguistring.h(645) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>c:\ogresdk\include\cegui\ceguistring.h(860) : error C2059: syntax error : 'constant'
1>c:\ogresdk\include\cegui\ceguistring.h(863) : error C2039: 'len' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1>c:\ogresdk\include\cegui\ceguistring.h(863) : error C2597: illegal reference to non-static member 'std::basic_string<_Elem,_Traits,_Ax>::npos'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1>c:\ogresdk\include\cegui\ceguistring.h(863) : error C3867: 'std::basic_string<_Elem,_Traits,_Ax>::npos': function call missing argument list; use '&std::basic_string<_Elem,_Traits,_Ax>::npos' to create a pointer to member
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1>c:\ogresdk\include\cegui\ceguistring.h(863) : error C2568: '==' : unable to resolve function overload
1>Build log was saved at "file://c:\Documents and Settings\Simon Bakkevig\Mine dokumenter\Skole\Hovedoppgave 08-09\herbert_game\herbert_game\obj\Debug\BuildLog.htm"
1>herbert_game - 7 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I posted here because the error concerned a CGUI header file.
I hope someone can help me.
Re: Compiling error in CEGUIString.h
Posted: Tue May 12, 2009 18:50
by Hedgehog
Is there no one who can help me with this?
Re: Compiling error in CEGUIString.h
Posted: Wed May 13, 2009 16:38
by Jamarr
Sorry, I have no idea. I don't use OGRE and I've never seen that problem. Have you tried asking over on the OGRE forums? Perhaps someone over there has seen it before.
Doing a quick search here did not really turn up much, though I did not look long. Do you perhaps have CEGUI_USEOLDOGRESTRING defined somewhere? I am not very familiar with this preprocessor define but it seems to have something to do with old versions of ogre and cegui strings; perhaps this was necessary for the version of ogre you upgraded from, and is no longer necessary?
That's about all the help I can give you.
Re: Compiling error in CEGUIString.h
Posted: Fri May 15, 2009 00:40
by earthsruler
Code Please.
Re: Compiling error in CEGUIString.h
Posted: Fri May 15, 2009 11:00
by Hedgehog
This is my setup file
ogre_setup.h
Code: Select all
#include "tour.h"
#include "frameListener.h"
#include <windows.h>
#include <Ogre.h>
#include <OIS/OIS.h>
#include <CEGUI/CEGUI.h>
#include <OgreCEGUIRenderer.h>
#undef min
#undef max
using namespace Ogre;
//Ogre start up. Replacement for ExampleApplication.h
class Application
{
public:
void go()
{
t = tour();
createRoot();
defineResources();
setupRenderSystem();
createRenderWindow();
initializeResourceGroups();
setupInputSystem();
setupScene();
setupCEGUI();
loadNodes();
createFrameListener();
startRenderLoop();
}
~Application()
{
try{
//Deletes root and frameListener objects
delete mListener;
delete mRoot;
//Deletes OIS objects
mInputManager->destroyInputObject(mKeyboard);
OIS::InputManager::destroyInputSystem(mInputManager);
}
catch(Exception e){}
}
protected:
Root *mRoot;
OIS::Keyboard *mKeyboard;
OIS::Mouse *mMouse;
OIS::InputManager *mInputManager;
CEGUI::OgreCEGUIRenderer *mRenderer;
CEGUI::System *mSystem;
FrameListener *mListener;
RenderWindow *mWindow;
SceneManager *mSceneMgr;
Camera *mCamera;
Vector3 objects[9];
tour t;
SceneNode* cam_node;
virtual void createRoot()
{
mRoot = new Root();
}
virtual void defineResources()
{
String secName, typeName, archName;
ConfigFile cf;
cf.load("resources.cfg");
ConfigFile::SectionIterator seci = cf.getSectionIterator();
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
ConfigFile::SettingsMultiMap *settings = seci.getNext();
ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName);
}
}
}
virtual void setupRenderSystem()
{
mRoot->restoreConfig();
}
virtual void createRenderWindow()
{
mWindow = mRoot->initialise(true);
}
virtual void initializeResourceGroups()
{
TextureManager::getSingleton().setDefaultNumMipmaps(5);
ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
}
virtual void setupScene()
{
Entity *ent;
mSceneMgr = mRoot->createSceneManager(ST_GENERIC, "Default SceneManager");
mCamera = mSceneMgr->createCamera("PlayerCam");
mCamera->setPosition(Vector3(300,120,-300));
mCamera->lookAt(Vector3(300,120,300));
mCamera->setNearClipDistance(5);
Viewport *v = mWindow->addViewport(mCamera);
Vector3 mSize(2219,410,1554);
ent = mSceneMgr->createEntity("Herbert_Game", "herbert_game.mesh");
SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
node->attachObject(ent);
node->yaw(Degree(180));
mSceneMgr->setAmbientLight(ColourValue(0.6,0.6,0.6));
const OIS::MouseState &ms = mMouse->getMouseState();
ms.width = v->getActualWidth();
ms.height = v->getActualHeight();
}
virtual void setupInputSystem()
{
//Sets up OIS input
size_t windowHnd = 0;
std::ostringstream windowHndStr;
OIS::ParamList pl;
RenderWindow *win = mRoot->getAutoCreatedWindow();
win->getCustomAttribute("WINDOW", &windowHnd);
windowHndStr << windowHnd;
pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
mInputManager = OIS::InputManager::createInputSystem(pl);
try
{
mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, true)); //change false to true for buffered input
mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, true));
}
catch (const OIS::Exception &e)
{
throw Exception(42, e.eText, "Application::setupInputSystem");
}
}
virtual void setupCEGUI()
{
//CEGUI setup (need to add CEGUIBase_d.lib OgreGUIRenderer_d.lib to links->input->Additional Dependencies)
mRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mSceneMgr);
mSystem = new CEGUI::System(mRenderer);
CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLook.scheme");
mSystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
CEGUI::MouseCursor::getSingleton().setImage(CEGUI::System::getSingleton().getDefaultMouseCursor());
}
virtual void createFrameListener()
{
mListener= new BufferedInputHandler(mWindow, mCamera, mSceneMgr, t, mKeyboard, mMouse);
mRoot->addFrameListener(mListener);
}
void startRenderLoop()
{
mRoot->startRendering();
}
virtual void loadNodes(void){
objects[0] = Vector3(0,-1000,0);
objects[1] = Vector3(148,2,314);
objects[2] = Vector3(-846,112,292);
objects[3] = Vector3(389,2,-372);
objects[4] = Vector3(-781,60,-370);
objects[5] = Vector3(469,229,-432);
objects[6] = Vector3(-426,85,422);
objects[7] = Vector3(591,2,-509);
objects[8] = Vector3(0,0,0);
t.setManager(mSceneMgr);
t.loadObjects(objects);
t.setupTour("senario.txt");
t.setupHint("hint.txt");
t.objs[1].setVisibility(true);
}
};
This is my input listener.
frameListener.h:
Code: Select all
#include <sstream>
#include <string>
#include <Ogre.h>
#include <windows.h>
#include <OIS/OIS.h>
#include <CEGUI/CEGUI.h>
#include <OgreCEGUIRenderer.h>
#undef min
#undef max
using namespace Ogre;
CEGUI::MouseButton convertButton(OIS::MouseButtonID buttonID)
{
switch (buttonID)
{
case OIS::MB_Left:
return CEGUI::LeftButton;
case OIS::MB_Right:
return CEGUI::RightButton;
case OIS::MB_Middle:
return CEGUI::MiddleButton;
default:
return CEGUI::LeftButton;
}
}
class BufferedInputHandler : public OIS::KeyListener, public OIS::MouseListener, public FrameListener
{
private:
OIS::Keyboard *keyboard;
OIS::Mouse *mouse;
CEGUI::WindowManager *wmgr;
CEGUI::Window *text, *title, *description, *hint;
CEGUI::Window *newG, *quit;
CEGUI::Window *menuRoot, *guiRoot;
Camera *mCam;
SceneManager *mSceneMgr;
bool mContinue, menuSet;
Vector3 mDirection;
Real mMove;
Real mRotate;
RaySceneQuery *mRayQuery;
Real terrainHeight;
tour to;
int mCounter;
public:
BufferedInputHandler(RenderWindow* win, Camera* cam, SceneManager *sceneMgr, tour t, OIS::Keyboard *kb = 0, OIS::Mouse *ms = 0)
{
mSceneMgr = sceneMgr;
mCounter = 0;
mMove = 200;
mRotate = 0.13;
terrainHeight = 0.0;
mContinue = true;
menuSet = true;
keyboard = kb;
mouse = ms;
mCam = cam;
to = t;
keyboard->setEventCallback(this);
mouse->setEventCallback(this);
// Create RaySceneQuery
mRayQuery = mSceneMgr->createRayQuery(Ray());
mDirection = Vector3::ZERO;
mCam->setFixedYawAxis(true);
wmgr = CEGUI::WindowManager::getSingletonPtr();
menuRoot = wmgr->loadWindowLayout("mainMenu.layout");
guiRoot = wmgr->loadWindowLayout("mainGUI.layout");
CEGUI::System::getSingleton().setGUISheet(menuRoot);
quit = wmgr->getWindow((CEGUI::utf8*)"Root/Quit");
quit->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&BufferedInputHandler::quitGame, this));
newG = wmgr->getWindow((CEGUI::utf8*)"Root/New");
newG->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&BufferedInputHandler::newGame, this));
}
bool BufferedInputHandler::quitGame(const CEGUI::EventArgs& arg){
mContinue = false;
return true;
}
bool BufferedInputHandler::newGame(const CEGUI::EventArgs& arg){
menuSet = false;
CEGUI::System::getSingleton().setGUISheet(guiRoot);
to.objs[mCounter].setVisibility(true);
title = wmgr->getWindow((CEGUI::utf8*)"Root/Info");
title->setText(to.objs[mCounter].title);
title->setVisible(true);
description = wmgr->getWindow((CEGUI::utf8*)"Root/Info/Text");
description->setText(to.objs[mCounter].description);
hint = wmgr->getWindow((CEGUI::utf8*)"Root/Hint/Text");
hint->setText(to.objs[mCounter].hint);
return true;
}
bool BufferedInputHandler::loadMenu(){
menuSet = true;
newG->setText("Continue");
CEGUI::System::getSingleton().setGUISheet(menuRoot);
return true;
}
bool frameStarted(const FrameEvent &evt)
{
keyboard->capture();
mouse->capture();
Vector3 pos = mCam->getPosition();
if(mDirection != Vector3::ZERO)
title->setVisible(false);
mCam->moveRelative(mDirection * evt.timeSinceLastFrame);
Vector3 temp = mCam->getPosition();
temp.y = terrainHeight + 120.0f;
mCam->setPosition(temp);
return mContinue;
}
//KeyListener
virtual bool keyPressed(const OIS::KeyEvent &arg) {
CEGUI::System *sys = CEGUI::System::getSingletonPtr();
sys->injectKeyDown(arg.key);
sys->injectChar(arg.text);
if(menuSet)
return true;
switch(arg.key)
{
case OIS::KC_ESCAPE:
BufferedInputHandler::loadMenu();
break;
case OIS::KC_W:
mDirection.z -= mMove;
break;
case OIS::KC_S:
mDirection.z += mMove;
break;
case OIS::KC_A:
mDirection.x -= mMove;
break;
case OIS::KC_D:
mDirection.x += mMove;
break;
}
return true;
}
virtual bool keyReleased(const OIS::KeyEvent &arg) {
CEGUI::System::getSingleton().injectKeyUp(arg.key);
if(menuSet)
return true;
switch (arg.key)
{
case OIS::KC_W:
mDirection.z += mMove;
break;
case OIS::KC_S:
mDirection.z -= mMove;
break;
case OIS::KC_A:
mDirection.x += mMove;
break;
case OIS::KC_D:
mDirection.x -= mMove;
break;
}
return true;
}
// MouseListener
virtual bool mouseMoved(const OIS::MouseEvent &arg) {
CEGUI::System::getSingleton().injectMouseMove(arg.state.X.rel, arg.state.Y.rel);
if (arg.state.buttonDown(OIS::MB_Right) && !menuSet)
{
mCam->yaw(Degree(-mRotate * arg.state.X.rel));
mCam->pitch(Degree(-mRotate * arg.state.Y.rel));
}
return true;
}
virtual bool mousePressed(const OIS::MouseEvent &arg, OIS::MouseButtonID id) {
CEGUI::System::getSingleton().injectMouseButtonDown(convertButton(id));
if (arg.state.buttonDown(OIS::MB_Right) && !menuSet){
CEGUI::MouseCursor::getSingleton().hide();
}
if (arg.state.buttonDown(OIS::MB_Left) && !menuSet){
Real normX = Ogre::Real(arg.state.X.abs)/arg.state.width;
Real normY = Ogre::Real(arg.state.Y.abs)/arg.state.height;
Ray mouseRay = mCam->getCameraToViewportRay( normX, normY );
mRayQuery->setRay(mouseRay);
mRayQuery->setSortByDistance(true);
RaySceneQueryResult &result = mRayQuery->execute();
RaySceneQueryResult::iterator i;
RaySceneQueryResult::iterator i_final;
i_final = result.end();
i = result.begin();
for ( i=result.begin(); i!=i_final; ++i)
{
MovableObject* wf = i->movable;
Real distance = i->distance;
for(int j = 0; j < 9; j++){
std::stringstream ss;
ss << to.objs[j].name;
std::string test = wf->getName();
if (to.objs[j].ent->isVisible()){
if (wf->getName() == to.objs[j].name){
title->setVisible(true);
title->setText(to.objs[j].title);
hint->setText(to.objs[j].hint);
description->setText(to.objs[j].description);
if(j != 8){
mCounter = j+1;
to.objs[j].setVisibility(false);
to.objs[j+1].setVisibility(true);
}
break;
}
}
}
}
}
return true;
}
virtual bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id) {
CEGUI::System::getSingleton().injectMouseButtonUp(convertButton(id));
CEGUI::MouseCursor::getSingleton().show();
return true;
}
};
There are a few other files but does not use CEGUI.
edit: removed some unnecessary code
Re: Compiling error in CEGUIString.h
Posted: Fri May 15, 2009 15:19
by jacmoe
My includes are:
Code: Select all
#include <CEGUI.h>
#include <CEGUISystem.h>
#include <CEGUISchemeManager.h>
#include <OgreCEGUIRenderer.h>
CEGUISystem includes CEGUIString..
Re: Compiling error in CEGUIString.h
Posted: Fri May 15, 2009 15:40
by Hedgehog
I don't think its the includes that's the problem.
When I comment out all the CEGUI code the error is of course gone, but as soon as I try to include the CEGUI.h file, with all other CEGUI code still commented out, the error returns.
Re: Compiling error in CEGUIString.h
Posted: Fri May 15, 2009 16:13
by Jamarr
You have to provide more information. You can't just post a compiler-error saying "it doesn't work. here is some generic error" and expect everyone to know what your build environment is. Not everyone here uses ogre and whatever build system you have in place.
What version of CEGUI are you actually using (CEGUIVersion.h)?
What compiler/configuration are you using?
And why not post the code-segments generating the errors, eg: CEGUIString.h lines 644, 645, 860, 863, etc...
Re: Compiling error in CEGUIString.h
Posted: Fri May 15, 2009 17:03
by Hedgehog
Okey, I should have thought of that before I posted, sorry.
I use VS2008, version 0.5.1 (included in the Ogre sdk)
The code where the error is:
line 644-647
Code: Select all
size_type size(void) const
{
return d_cplength;
}
line 855-872
Code: Select all
int compare(size_type idx, size_type len, const std::string& std_str, size_type str_idx = 0, size_type str_len = npos) const
{
if (d_cplength < idx)
throw std::out_of_range("Index is out of range for CEGUI::String");
if (std_str.size() < str_idx)
throw std::out_of_range("Index is out of range for std::string");
if ((len == npos) || (idx + len > d_cplength))
len = d_cplength - idx;
if ((str_len == npos) || (str_idx + str_len > std_str.size()))
str_len = (size_type)std_str.size() - str_idx;
int val = (len == 0) ? 0 : utf32_comp_char(&ptr()[idx], &std_str.c_str()[str_idx], (len < str_len) ? len : str_len);
return (val != 0) ? ((val < 0) ? -1 : 1) : (len < str_len) ? -1 : (len == str_len) ? 0 : 1;
}
Hope this helps you help me :p
Re: Compiling error in CEGUIString.h
Posted: Sat May 16, 2009 00:03
by jacmoe
Hedgehog wrote:I don't think its the includes that's the problem.
Did you actually try including the other files? Or are you just guessing?
I run almost exactly the same code as you do, and have no problems.
Re: Compiling error in CEGUIString.h
Posted: Sat May 16, 2009 02:32
by Hedgehog
Yes I tried all the includes you suggested and I still get the error.
Its very strange, with no extra code but includes I still get the error.
Re: Compiling error in CEGUIString.h
Posted: Sat May 16, 2009 03:02
by jacmoe
I see you are including a lot of stuff.
Remove #include <windows> and see what happens.
Re: Compiling error in CEGUIString.h
Posted: Sat May 16, 2009 04:05
by Hedgehog
Tried that, no change.
Begging to believe that there is something wrong with my Ogre installation.
Just to be sure, I'll reinstall it.
Edit: reinstall didn't help
Re: Compiling error in CEGUIString.h
Posted: Sat May 16, 2009 13:59
by scriptkid
Hi,
this is just a wild shot, but are you using the MS standard library, or some other like stlport?
Re: Compiling error in CEGUIString.h
Posted: Sat May 16, 2009 14:32
by Hedgehog
I am using standard MS libs.