Advertisement

0xC0000005: Access violation reading location

Started by August 01, 2024 09:46 AM
6 comments, last by AloeSnapz 1 week, 2 days ago

I`m getting this error when I`m trying to run the code from an Ogre3d tutorial. From what I`ve read on the internet it might have to do with string formatting but I do not understand exactly what the problem is.

This is the code that I`m using:

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

I get the error at cf.load("resources.cfg"); line. If I specify an absolute path for that file

cf.load("C:/Ogre/bin/resources.cfg");

I get an Ogre::FileNotFoundException

The file is there. The VS Working Directory is set to $(TargetDir) The VS Output Directory is set to ..\..\..\..\..\..\Ogre\bin

Any ideas how to get the problem fixed? Thanks

My project`s facebook page is “DreamLand Page”

Calin said:
cf.load(

Try double backslashes “c:\\Ogre\\…”

Besides, ideally you can set a breakpoint and debug what cf.load is doing. It should show where the crash happens in more detail. Afaik, this even works if the function is in a debug dll.

Advertisement

I tried double backslashes and a number of other things, nothing seems to work. I give up I`m not going to waste time trying to get it to work, I`ll keep using GDI+

Offtopic: posting from mobile seems to be broken.

My project`s facebook page is “DreamLand Page”

Calin said:
I give up I`m not going to waste time trying to get it to work, I`ll keep using GDI+

Known feeling. My plan to migrate to linux is still just wishful thinking. It takes time to figure out alternatives to Visual Studio, and i don't enjoy such research.

But giving up doesn't help it. You need better visualization and ideally some GUI to improve your working conditions. And in case you're not very familiar with the debugger, that's the very first thing you should check out.

Not sure if Ogre is a good choice, though. I don't know it, but it's a complex 3D engine.
I'd look for simpler frameworks.

You need better visualization

I know, I`ll switch at some point in the future. I think I can add more features without changing my current graphics setup.

JoeJ said:
Not sure if Ogre is a good choice

I did things with Ogre before. I was hopping I can resume where I had left.

My project`s facebook page is “DreamLand Page”

1. Verify the File Location

  • Double-check that resources.cfg is indeed located in the directory C:/Ogre/bin/.
  • Ensure there are no typos in the file name or directory path.

2. Check VS Working Directory

  • The working directory set in Visual Studio determines where your program looks for files when you specify a relative path. You mentioned that the working directory is set to $(TargetDir). Ensure that $(TargetDir) is correctly pointing to the directory where your resources.cfg file is located.

3. Absolute Path Test

  • When using an absolute path like cf.load("C:/Ogre/bin/resources.cfg"); and getting an Ogre::FileNotFoundException, there might be issues with access rights, or the file might not be where you expect it to be.
  • Try running your Visual Studio as an administrator to eliminate any permission issues.

4. Relative Path Issues

  • If using a relative path (like just "resources.cfg"), ensure that the file is in the directory that the working directory resolves to during runtime. You can confirm the working directory by printing the current working directory at runtime using something like:

    char buffer[MAX_PATH];
    _getcwd(buffer, MAX_PATH);
    std::cout << "Current working directory: " << buffer << std::endl;

5. Environment Variables and Configuration

  • Ensure that your Visual Studio environment variables (like $(TargetDir)) are correctly set. You can inspect and modify these in the project's properties under Configuration Properties -> Debugging -> Working Directory.
  • Alternatively, set the path explicitly using cf.load("relative/path/to/resources.cfg");.

6. Ogre3D Configuration

  • Ogre might be using a specific path prefix or expecting resources in a particular folder relative to the executable. Check if there's any documentation about resource paths in Ogre3D, especially if you're running in a development environment where paths might differ.

7. Permissions

  • Ensure that your application has permission to access the directory and file. This could be an issue, especially if you're working on a system with strict file access controls.

-Aloesnapz …slaps?

Advertisement

https://forums.ogre3d.org/viewforum.php?f=2 This might also have someone who knows a little more about OGRE

-Aloesnapz …slaps?

Advertisement