First off, sorry if this is the wrong section, but sense I'm working with graphics, I thought it would be more appropriate for the game dev topic.

Okay, whenever I start debugging from VC++, I segfault. But when I run my program outside of VC++, it runs perfectly fine.

If I need to add more details, please tell me, I'm just confused haha.

Thanks,
~EpicAsian

Can you produce the smallest piece of code that does this and post it here?

Dave

Well, I would like to, but it happens in random places. In a class of my engine, in the constructor it takes a filename argument and loads and optimizes that image.It segfaulted there once. Another time, it segfaulted when I flipped the buffer to the screen in SDL.

My guess is that VC++ is looking for the image file I specified in a temporary directory and it's not there.

Thanks for the reply,
~EpicAsian

You should be able to set the "working directory" in VC. That is where it will look for images without a path specified. Another thing you could check is that VC has the same library path order that your system has. Maybe it is linking to different versions of the libraries that you are using?

I don't think it's linking to a different version of the SDL library, because I download VC++ and SDL at the same time. I recently converted from Dev-C++ to VC++, so I'm somewhat new to the VS environment. I don't see why VC++ would be throwing errors if the images are in the same directory as the *.exe.

Thanks,
~EpicAsian

Look for data not set! You should probably have a difference between a debug and release build as well. Data will be initialized differently. Also running within an I.D.E. will move code around in memory!

Also look for a memory overwrite. Writing past the end of allocated memory. Check for unhandled errors.

Single-step your code!

commented: good answer +28

If your code doesn't work within the IDE, there's no question of shipping it ever.

The debugger does you a huge favour by watching what you're doing with the memory and tells you when your code does something insane (like stomping on memory that it doesn't own).

Single stepping should help you find the problem.

commented: good answer +28
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.