Bad memory allocation (C++)

I’ve installed Panda3D under Visual Studio 2005.
Directories are set to:
Include:
D:\Panda3D-1.4.2\include
D:\Panda3D-1.4.2\thirdparty\win-libs-vc8\nspr\include
D:\Panda3D-1.4.2\thirdparty\win-python\include
Libraries:
D:\Panda3D-1.4.2\lib
D:\Panda3D-1.4.2\thirdparty\win-python\libs

Linker->Input: libpanda.lib libpandaexpress.lib libp3framework.lib libp3dtool.lib libp3dtoolconfig.lib
Ignore Specyfic Library: python24_d.lib

C/C++ ->Preprocessor: WIN32;_DEBUG;_CONSOLE;WIN32_VC

#include "pandaFramework.h"
#include "pandaSystem.h"

PandaFramework framework;

int main(int argc, char* argv[]){
	framework.open_framework(argc,argv);
	framework.set_window_title("Hello");
	WindowFramework *window = framework.open_window();

	framework.main_loop();
	framework.close_framework();
	return 0;
}

And when I compile it and run I’m getting this error:
“Unhandled exception at 0x7c81eb33 in ArkanosVC8.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012f75c…”

Which is pointing on this line:

framework.set_window_title("Hello");

When it is commented it works fine, but why there’s an error?
Can someone help me with this? I’m trying to solve this for 2h :[

I’m guessing it’s a debug/release build conflict. You have to be sure that all of the DLL’s you link together are the same kind of build: they all have to be debug build, or they all have to be release build.

The Panda convention is the same as the Python convention here: debug build libraries are named _d, for instance, libpanda_d.dll. If you are linking with libpanda.dll, which is a release build, you will need to configure your build as a release build too.

David

Thank you very much! :smiley: Now it works fine :slight_smile:

Pardon my noobiness, but I’m having the same unhandled exception as j4ck. I understand the concept of debug/release difference, but what I can’t figure out is how to make sure all the dlls are either debug or release. I don’t see any _d.dll files in Panda3D directory.

I’m confused, tips on how to set this up will be greatly appreciated!

Edit: I changed it to release configuration (top menu bar have option for Debug or Release) and it compiled. However when I exit the program, it gives me an unhandled exception:

Unhandled exception at 0x00a6fba7 in PandaCpp2.exe: 0xC0000005: Access violation writing location 0x0000000a.

I wanted to see if Panda works, so I continued with tutorial and ignored this error. When I got to the camera rotation part, the camera doesn’t move. Here’s a screenshot:

i18.photobucket.com/albums/b102/ … assert.jpg

So I think it have to do something with the first error with program exiting.

So my two questions are: How do I compile it under debug configuration, and how do I fix this error? Thanks!

If you’re linking against the official Panda build, make sure you are compiling in Release build yourself.

I edited my post when you posted yours. I’ll set it to release configuration. Disregard my first question from previous post. Second question still there.

Thanks!

You’ll just need to grab the panda source from the download page, and compile it in Debug configuration using the supplied .sln file.

This will help you with that:
panda3d.org/manual/index.php/Tutor … on_Windows