C++ Panda Hello World Debug error

Hi all,
I am trying to build the Panda Hello World code. It works well under release mode.

But under debug mode, when i try to step into framework.set_window_title();

int main(int argc, char *argv[]) {
//open a new window framework
framework.open_framework(argc, argv);
//set the window title to My Panda3D Window
framework.set_window_title(“My Panda3D Window”);

there is an error message:
Unhandled exception at 0x7c812a5b in HelloWorld.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012f75c…

Any ideas about how to solve this debug problem?
BTW, python_d.lib is installed.

Thanks.

Tom

Does it crash only in the debugger, or also when you run it directly?

Are you sure you’re linking with the right dll’s, and not linking with dll’s built from some other version of Panda (for instance, with the release version)?

David

Hi David,

Thanks for pointing out this.
I just installed Panda3D and didn’t recompile Panda3D from sourcecode.
Do you mean that I need to recompile Panda3D to get the debug dll in order to debug my own code?
Or is there any place that i can download the Panda3D debug dll?

Thanks.

Tom

If you build your application using the standard “debug” templates, then you will need to link with with Panda dll’s that have also been build “debug” (which pretty much means you’ll have to get your own Panda and build it yourself).

This is because Microsoft uses two different and incompatible runtime libraries, one for “debug” programs, and one for “release” programs. This is why you need a special debug version of Python too, built as python_d.dll.

That doesn’t mean that you need to do this for debugging, though. It’s possible to debug an application that was built with “release” mode. It’s just a little more confusing.

David

Hi David,

Thanks for your quick reply and detailed explanation:-)

Finally i got to debug my code through using Multithreaded Dll Runtime instead of Multithreaded Debug Dll Runtime (changed in project property page under c/c++/Code generation). I don’t know why but the code can be debugged in an application that was built with “release” mode.

Tom

I would guess that the only difference between the microsoft debug libraries and the microsoft release libraries is that the debug libraries actually allow you to debug the microsoft libraries themselves. Which isn’t so important.

No, there’s a huge difference. The debug libraries use a completely different malloc/free scheme than the release libraries. The malloc/free scheme provided in the debug libraries provides more checking for array overruns and the like; however, the fact that it is a different scheme means that you absolutely cannot mix and match debug and release runtime libraries within the same application. If Panda is built to link against the release libraries, then your application must link against them too.

However, debug symbols can be provided regardless of the runtime library you are using, so it is possible to use the debugger to step through your application in either case.

David