I got a strange problem.
I am using Visual Studio 2005 SP1, Ogre 1.60, build my project with no errors.
But when I run the appication after build(in Visual Studio, ctrl + F5), I got crash at this line
and run into output.c (looks like a windows file...)
But if I close Visual Studio and just go to the bin/release folder, double click the .exe, It can run with no crashes....
I hope someone can help me with this.
Because I can build project but cannot debug it, this is difficult to me
I am using Visual Studio 2005 SP1, Ogre 1.60, build my project with no errors.
But when I run the appication after build(in Visual Studio, ctrl + F5), I got crash at this line
-
Code:
Select all
-
cf.load(m_ResourcePath + "resources.cfg");
and run into output.c (looks like a windows file...)
-
Code:
Select all
-
#else /* _UNICODE */ if (flags & (FL_LONG|FL_WIDECHAR)) { if (text.wz == NULL) /* NULL passed, use special string */ text.wz = __wnullstring; bufferiswide = 1; pwch = text.wz; while ( i-- && *pwch ) ++pwch; textlen = (int)(pwch - text.wz); /* textlen now contains length in wide chars */ } else { if (text.sz == NULL) /* NULL passed, use special string */ text.sz = __nullstring; p = text.sz; while (i-- && *p) /// <-- crash here ++p; textlen = (int)(p - text.sz); /* length of the string */ }
But if I close Visual Studio and just go to the bin/release folder, double click the .exe, It can run with no crashes....
I hope someone can help me with this.
Because I can build project but cannot debug it, this is difficult to me
-
wilsonwing
- Halfling
- Posts: 63
- Kudos: 1
- Joined: 14 Jan 2008
- Location: Taipei Taiwan
Re: Problem cf.load(m_ResourcePath + "resources.cfg")
This is a common problem.
You have to understand what is the 'application path' or 'working directory' when running in VS IDE vs running it yourself ie double clicking the executable. The working directory when running it by double clicking is the executable directory itself. The working directory when running inside your VS IDE is the path of your <project>.vcproj. So this is the main reason why your app can't find the file because the executable location is different now. I always set the working directory by right-clicking on the project, and choose setting (or simply Alt+F7). Choose 'Debugging' under 'Configuration Properties', type in the proper working directory.
You have to understand what is the 'application path' or 'working directory' when running in VS IDE vs running it yourself ie double clicking the executable. The working directory when running it by double clicking is the executable directory itself. The working directory when running inside your VS IDE is the path of your <project>.vcproj. So this is the main reason why your app can't find the file because the executable location is different now. I always set the working directory by right-clicking on the project, and choose setting (or simply Alt+F7). Choose 'Debugging' under 'Configuration Properties', type in the proper working directory.
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
Re: Problem cf.load(m_ResourcePath + "resources.cfg")
syedhs wrote:This is a common problem.
I always set the working directory by right-clicking on the project, and choose setting (or simply Alt+F7). Choose 'Debugging' under 'Configuration Properties', type in the proper working directory.
Thanks for your help
This is what i do, my .exe is locate under E:\GameProject\bin\release\ [GameProject].exe
I do as you said, and put E:\GameProject\bin\release\ [GameProject].exe to the work directory, doesn't work.
ps.
This project was original write on the other computer, for some reason I have to move it to the computer I am using now.
It has no problem with the origin one.
And the program actually runs a little bit..
-
Code:
Select all
-
bool OgreNewtonApplication::setup() //almost the same as ExampleApplication in the wiki { String pluginsPath; // only use plugins.cfg if not static #ifndef OGRE_STATIC_LIB pluginsPath = m_ResourcePath + "plugins.cfg"; #endif //Ogre Root m_pOgreRoot = new Root(pluginsPath, m_ResourcePath + "ogre.cfg", m_ResourcePath + "Ogre.log"); setupResources(); ..... ..... return true; } void OgreNewtonApplication::setupResources() { // Load resource paths from config file ConfigFile cf; ********************************************************************************************************************************** ********************************************************************************************************************************** ********************************************************************************************************************************** ********************************************************************************************************************************** cf.load(m_ResourcePath + "resources.cfg"); //<---crash until here (only crash when run in VS2005) ********************************************************************************************************************************** ********************************************************************************************************************************** ********************************************************************************************************************************** ********************************************************************************************************************************** ********************************************************************************************************************************** ..... ..... }
-
wilsonwing
- Halfling
- Posts: 63
- Kudos: 1
- Joined: 14 Jan 2008
- Location: Taipei Taiwan
Re: Problem cf.load(m_ResourcePath + "resources.cfg")
Try changing working directory into 'E:\GameProject\bin\release\'
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
Re: Problem cf.load(m_ResourcePath + "resources.cfg")
syedhs wrote: Try changing working directory into 'E:\GameProject\bin\release\'
Cool , it works now:D
Thanks for helping me on this stupid problem