C++ error

Hi!
When i compile this code:

#include <pandaFramework.h>
#include <pandaSystem.h>
#include <animControlCollection.h>
#include <auto_bind.h>

PandaFramework framework;

int main(int argc, char* argv[])
{
    framework.open_framework(argc, argv);
    WindowFramework* win = framework.open_window();
    NodePath camera = win->get_camera_group();



    NodePath teapot = win->load_model(framework.get_models(), "teapot");
    teapot.reparent_to(win->get_render());
    teapot.set_pos(-5, 0, 0);
    NodePath panda = win->load_model(framework.get_models(), "panda");
    panda.reparent_to(win->get_render());
    panda.set_pos(5, 0, 0);
    win->load_model(panda, "panda-walk");
    AnimControlCollection pandaAnims;
    auto_bind(panda.node(), pandaAnims);
    pandaAnims.loop("panda_soft", false);
    camera.set_pos(0, -30, 6);
    framework.main_loop();
    framework.close_framework();
    return 0;
}

or other examples, compile successfully but when i run compiled app, The window closes suddenly and I get this error:

Attempt to register type x11GraphicsPipe more than once!
Attempt to register type x11GraphicsWindow more than once!
Known pipe types:
eglGraphicsPipe
glxGraphicsPipe
TinyXGraphicsPipe
TinyOffscreenGraphicsPipe
(all display modules loaded.)
Segmentation fault (core dumped)

please help me…

Put “PandaFramework framework;” inside “int main”.

Also, whenever you get a segfault, you can get more information with a stack trace, by typing “gdb yourprogram core” and then typing “bt” in the gdb prompt.